1
votes

How does scikit-learn's sklearn.linear_model.LogisticRegression class work with regression as well as classification problems?

As given on the Wikipedia page as well as a number of sources, since the output of Logistic Regression is based on the sigmoid function, it returns a probability. Then how does the sklearn class work as both a classifier and regressor?

1

1 Answers

1
votes

Logistic regression is a method for classification, not regression. This goes for scikit-learn as for anywhere else.

If you have entered continuous values as the target vector y, then LogisticRegression will most probably fail, as it interprets the unique values of y, i.e. np.unique(y) as different classes. So you may end up having as many classes as samples.

TL;DR: Logistic regression needs a categorical target variable, because it is a classification method.