Logistic Regression using Tensorflow
Logistic Regression is Classification algorithm commonly used in Machine Learning. It allows categorizing data into discrete classes by learning the relationship from a given set of labeled data. It learns a linear relationship from the given dataset and then introduces a non-linearity in the form of the Sigmoid function.
In case of Logistic regression, the hypothesis is the Sigmoid of a straight line, i.e,
where
w
represents the Weights and the scalar b
represents the Bias of the model.
Note that the range of the Sigmoid function is (0, 1) which means that the resultant values are in between 0 and 1. This property of Sigmoid function makes it a really good choice of Activation Function for Binary Classification. Also
for z = 0, Sigmoid(z) = 0.5
which is the midpoint of the range of Sigmoid function.
Just like Linear Regression, we need to find the optimal values of w and b for which the cost function Jis minimum. In this case, we will be using the Sigmoid Cross Entropy cost function which is given by
This cost function will then be optimized using Gradient Descent.
This cost function will then be optimized using Gradient Descent.
Implementation:
We will start by importing the necessary libraries. We will use Numpy along with Tensorflow for computations, Pandas for basic Data Analysis and Matplotlib for plotting. We will also be using the preprocessing module of
We will start by importing the necessary libraries. We will use Numpy along with Tensorflow for computations, Pandas for basic Data Analysis and Matplotlib for plotting. We will also be using the preprocessing module of
Scikit-Learn
for One Hot Encoding the data.
No comments:
Post a Comment