Logistic regression is very similar to linear regression. As in both algorithms, models are trained to find a regression line to define function for futher prediction. Therefore, it's a form of supervised learning, which tries to predict the responses of unlabeled, unseen data by first training with labeled data, on a set of observations which consists of both independent (X) and dependent (Y) variables. But while <ahref='https://guide.freecodecamp.org/machine-learning/linear-regression'target='_blank'>Linear Regression</a> assumes that the response variable (Y) is quantitative or continuous, Logistic Regression is used specifically when the response variable is qualititative, or discrete.<br>
Logistic regression models the probability that Y, the response variable, belongs to a certain category. In many cases, the response variable will be a binary one, so logistic regression will want to model a function y = f(x) that outputs a normalized value that ranges from, say, 0 to 1 for all values of X, corresponding to the two possible values of Y. It does this by using the logistic function.
Logistic regression is the appropriate regression analysis to conduct when the dependent variable is dichotomous (binary), but it has another form such as mutivalued logistic regression which is used to classify for more than two classes. Like all regression analyses, the logistic regression is a predictive analysis. Logistic regression is used to describe data and to explain the relationship between one dependent binary variable and one or more nominal, ordinal, interval or ratio-level independent variables.
Logistic regression is used to solve classification problems, where the output is of the form y∈{0,1}. Here, 0 is a negative class and 1 is a positive class. Let's say we have a hypothesis hθ(x), where x is our dataset(a matrix) of length m. θ is the parameteric matrix. We have : 0 <hθ(x)<1
In Logistic regression, hθ(x) is a sigmoid function, thus hθ(x) = g(θ'x).
Where hθ(x) is = hypothetic value calculated in accordance with attributes and weights which are calculated and balanced via algorithm such as gradient descent.
Refer to this article for clearing your basics https://www.analyticsvidhya.com/blog/2017/06/a-comprehensive-guide-for-linear-ridge-and-lasso-regression/
into two classes.Like for sigmoid function 0.5 is set as the decision boundary all x for which y≥0.5 are classified as class A and for which y<0.5areclassifiedasclassB.
Although you will see logistic regression usually being used in case of binary classification, you can also use it in case of classification into multiple classes by:
- Click <ahref="https://medium.com/towards-data-science/building-a-logistic-regression-in-python-step-by-step-becd4d56c9c8"target='_blank'rel='nofollow'>here</a> for an article about building a Logistic Regression in Python.
- Click <ahref="http://nbviewer.jupyter.org/gist/justmarkham/6d5c061ca5aee67c4316471f8c2ae976"target='_blank'rel='nofollow'>here</a> for another article on building a Logical Regression.
- Click <ahref="http://nbviewer.jupyter.org/gist/justmarkham/6d5c061ca5aee67c4316471f8c2ae976"target='_blank'rel='nofollow'>here</a> for another article on mathematics and intuition behind Logical Regression.