Course outline
Chapter 2: Classification
Logistic Regression
From linear scores to probabilities with the sigmoid function and the cross-entropy loss.
The sigmoid function
To turn a real-valued score into a probability we use
Cross-entropy loss
Its gradient has the same form as in linear regression: .
In scikit-learn
from sklearn.linear_model import LogisticRegression
model = LogisticRegression(max_iter=1_000)
model.fit(X_train, y_train)
print(model.score(X_test, y_test))