Found 668 Articles for Machine Learning

Difference Between Linear and Logistic Regression

AmitDiwan
Updated on 25-Mar-2021 05:51:05

1K+ Views

In this post, we will understand the difference between linear regression and logistic regression.Linear RegressionIt helps predict the variable that is continuous, and is a dependent variable.This is done using a given set of independent variables.It extrapolates a line to find the value of dependent variable.Least square methods are used to estimate the accuracy.The best fit line is found, that helps predict the output.It is generally a continuous value.The relation between the dependent variable and independent variable has to be linear.The independent variables may have collinearity between them.It is considered a machine learning problem, i.e an applied statistics problem.Logistic RegressionIt ... Read More

How to move the Y-axis ticks from the left side of the plot to the right side in matplotlib?

Rishikesh Kumar Rishi
Updated on 15-Mar-2021 07:28:01

7K+ Views

To shift the Y-axis ticks from left to right, we can perform the following steps −Create a figure using the figure() method.Using the above figure method, create the axis of the plot, using add_subplot(xyz), where x is row, y is column, and z is index.To shift the Y-axis ticks from left to right, use ax.yaxis.tick_right() where ax is axis created using add_subplot(xyz) method.Now plot the line using plot() method, with given x and y points, where x and y points can be created using np.array() method.Set up x and y labels, e.g., X-axis and Y-axis , using xlabel and ylabel ... Read More

How can Tensorflow Hub be used to fine-tune learning models?

AmitDiwan
Updated on 25-Feb-2021 07:42:50

303 Views

TensorFlow Hub is a repository that contains trained machine learning models. These models are ready to be fine-tuned and deployed anywhere. The trained models such as BERT and Faster R-CNN can be reused with a few lines of code. It is an open-repository, which means it can be used and modified by anyone.The tfhub.dev repository contains many pre-trained models. Some of them include text embeddings, image classification models, TF.js/TFLite models and so on.It can be installed using the below code:!pip install --upgrade tensorflow_hubIt can be imported into the working environment as shown in the below code:import tensorflow_hub as hub Read More

How can a customized model be pre-trained?

AmitDiwan
Updated on 25-Feb-2021 06:57:48

381 Views

A sequential model can be built using Keras Sequential API that is used to work with plain stack of layers. Here every layer has exactly one input tensor and one output tensor.A pre-trained model can be used as the base model on the specific dataset. This saves the time and resources of having to train the model again on the specific dataset.A pre-trained model is a saved network which would be previously trained on a large dataset. This large dataset would be a large-scale image-classification task. A pre-trained model can be used as it is or it can be customized ... Read More

Plotting regression and residual plot in Matplotlib

Dev Prakash Sharma
Updated on 23-Feb-2021 18:14:13

2K+ Views

To establish a simple relationship between the observations of a given joint distribution of a variable, we can create the plot for the regression model using Seaborn.To fit the dataset using the regression model, we have to first import the necessary libraries in Python.We will create plots for each regression model, (a) Linear Regression, (b) Polynomial Regression, and (c) Logistic Regression.In this example, we will use the wine quality dataset which can be accessed from here, https://archive.ics.uci.edu/ml/datasets/wine+qualityExampleimport matplotlib.pyplot as plt import seaborn as sns from scipy.stats import pearsonr sns.set(style="dark", color_codes=True) #import the dataset wine_quality = pd.read_csv('winequality-red.csv', delimiter=';') #Plotting ... Read More

How to manage image resolution of a graph in Matplotlib

Dev Prakash Sharma
Updated on 23-Feb-2021 06:25:45

1K+ Views

An Image contains a 2-D matrix RGB data points which can be defined by the dots point per inch [ DPI ] of the image. The resolution of the image is important because a hi-resolution image will have much more clarity.We have a method ‘plt.savefig()’ in Matplotlib which determines the size of the image in terms of its pixels. Ideally it is having an ‘dpi’ parameter.Let’s see how we can manage the resolution of a graph in Matplotlib.Exampleimport matplotlib.pyplot as plt import numpy as np #Prepare the data for histogram np.random.seed(1961) nd = np.random.normal(13, 5, 1000) #Define the ... Read More

How to provide shadow effect in a Plot using path_effect attribute in Matplotlib

Dev Prakash Sharma
Updated on 23-Feb-2021 06:25:32

1K+ Views

In order to provide path effects like shadow effect in a plot or a graph, we can use the path_effect attribute.For example, let’s see how we can use the path_effect attribute in Matplotlib add a shadow effect to a sigmoid function.import matplotlib.pyplot as plt import numpy as np from matplotlib.patheffects import PathPatchEffect, SimpleLineShadow, NormalNow let us define the size of the figure and plot the sigmoid function, plt.style.use('seaborn-deep') plt.subplots(figsize=(10, 10))Let us define the datapoints for the plot, x = np.linspace(-10, 10, 50) y = 1+ np.exp(-x))Let us define the shadow property in the plot, plt.plot(x, y, linewidth=8, color='blue', path_effects= [SimpleLineShadow(), ... Read More

How to plot with multiple color cycle using cycler property in Matplotlib

Dev Prakash Sharma
Updated on 23-Feb-2021 06:21:53

835 Views

Matplotlib has a default color cycle for all the graphs and plots, however, in order to draw plots with multiple color cycles, we can use the cycler property of Matplotlib. It is used to plot repetitive patterns for the axis.First, we will use the Object Oriented APIs such as pyplot to plot the specific visualization.from cycler import cycler import numpy as np from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas from matplotlib.figure import Figure from IPython.core.display import displayIn this example, we will create two objects which will repeat the cycle after every four objects. Thus, after creating two objects, the last two ... Read More

How to plot Time Zones in a map in Matplotlib

Dev Prakash Sharma
Updated on 23-Feb-2021 14:46:09

505 Views

Let us consider that we have some data in which we have to deal with the actual time. To plot the time-zones on the map, we can use the ‘cartopy’ or ‘metPy’ package in Python. However, we can install ‘cartopy’ package in the Anaconda environment using the commands, conda install -c conda-forge cartopyOrconda install -c conda-forge metpyNow, let’s see how to plot time zones in a map using Matplotlib.Exampleimport numpy as np import cartopy.crs as ccrs import matplotlib.animation as animation import matplotlib.pyplot as plt #Defining the plot size and axes plt.figure(figsize=(10, 9)) ax = plt.axes(projection=ccrs.PlateCarree()) #Apply the color ... Read More

How to plot Exponentially Decaying Function using FuncAnimation in Matplotlib

Dev Prakash Sharma
Updated on 23-Feb-2021 06:17:50

288 Views

Let us assume that we want to animate a nature of function which is exponentially decaying like y = a(b)^x where b = growth factor and a = initial value.An exponentially decay function would look like this, However, for now, we want to animate and plot the exponentially decaying tan function.First import the libraries, import numpy as np import matplotlib.pyplot as plt from matplotlib.animation import FuncAnimationDefine the axes, fig, a = plt.subplots()Plotting a blank figure with axes,   xdata, ydata = [], [] line, = ax.plot(xdata, ydata)Set the limit of the grids, ax.set_xlim(0, 10) ax.set_ylim(-3.0, 3.0) ax.grid()   Define the function to ... Read More

Advertisements