Logistic Regression

Logistic regression is a classification model that predicts the probability an input belongs to a class, outputting a value between 0 and 1 that is then turned into a yes/no decision.

Data & AI

Despite the name 'regression,' it's used for classification. It applies a special S-shaped function (the sigmoid) to squash a linear combination of features into a probability, then picks a class based on a threshold like 0.5.

For example, given a tumor's size it might output 0.9, meaning 90% likely malignant. It's a fast, interpretable baseline for binary classification problems and a building block of neural networks.

Examples

Python

from sklearn.linear_model import LogisticRegression

clf = LogisticRegression().fit(X_train, y_train)
print(clf.predict_proba([[2.0]])[0].round(2))

Output:

[0.18 0.82]

Learn it in a lesson

See also

Back to the Dictionary