Logistic Regression
Logistic Regression
Logistic regression is one of the most popular and one of the most widely used
algorithms today. Before jumping into the logistic regression algorithm, we need to
understand some important concepts like classification, hyperplane
Classification
In machine learning, classification is identifying which set of categories the new
observation belongs to based on the set of training data containing the observed
categories.
In classification problems, the target variable (also known as predictor variable) which is
denoted by ‘y’ has discrete values. It’s a categorical variable.
In all the above problems, the predictor variable y can be thought of as taking on two
values either ‘0’ or ‘1’.
With respect to above examples, the values of the target variable could be spam or not
spam, fraudulent or not, flower of type or flower of type 2 or flower of type 3, malignant
or benign, cat or dog, positive or negative etc.
So ‘0’ may denote an image as a cat and ‘1’ may denote it as a dog. The assignment of
two classes is arbitrary.
The general intuition is that the negative class i.e. ‘0’ denotes the absence of something
and the positive class i.e. ‘1’ denotes the presence of something that we are looking for.
First we will consider the classification problems with two classes ‘0’ and ‘1’. It is also
called binary classification. All the above examples are of binary classification.
Later on we will see multiclass problems as well where the predictor variable ‘y’ may
take on values ‘0’, ’1’, ’2’, and ‘3’.
Multiclass Classification
JAvapoint
Let’s apply linear regression by trying to fit a straight line to the given data.You may get
a hypothesis which look like as follows:
https://www.excelr.com/blog/data-science/regression/understanding-logistic-regr
ession-using-r
The task of machine learning algorithm is to findthe best separating hyperplane. Also
known as the decision boundary. Let’s assume ‘N’ as the number of features. If the
value of ‘N’ is 2 then the line runs into 2-D feature space. The line need not be straight.
It could be curved as well.
Technically you can have infinite hyperplanes. If the data has 100 features then these
lines or curves will run into all those 100 dimensional feature space. It will no longer be
a line, in that case, it will be a plane. A plane which has very high dimensionality. That’s
the reason it’s named as hyperplane.
The curve is called as a non-linear hyperplane. In a 2-D feature space, the hyperplane
will look like a line or curve.
In a 3-D feature space, it will come up like a 2-D plane which could be a sheet. The
sheet could be a plane sheet or a curved sheet.
In 4-D these hyperplanes will look like 3-D volumes. It could be cuboid, parallelepiped
etc. This way there would be different shapes and interpretations. Interpreting beyond
3-D or 4-D generally would not be possible. Hence a generic word hyperplane is used
here.