Classification
Predict a class with logistic regression and read probabilities carefully.
What you will be able to do
- Use predict_proba to inspect confidence.
- Choose the threshold based on costs.
- Report precision and recall, not only accuracy.
- Check class balance before trusting accuracy.
In plain English
Classification predicts a category. Logistic regression outputs a probability that is converted to a class by a threshold. The threshold is a product decision, not a law of nature.
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import classification_report
model = LogisticRegression(max_iter=1000).fit(X_train, y_train)
pred = model.predict(X_test)
print(classification_report(y_test, pred))Your turn
MediumPredict probabilities
Fit logistic regression and return the probability of the positive class.
PYTHON · starter
model.predict(X_test)Check your understanding before moving on.
Knowledge checkQuestion 1
Why can accuracy be misleading?
Select an answer to continue
Study tools
Make it yours.
Keep a private note for this lesson, then turn the key ideas into flashcards you can revisit.
Sign in to save notes and flashcards.Both are private to your account and stay with your progress.
Sign inFinished reading?
Lock in what you just learned.
0%
Mark this lesson complete to save your place and move one step closer to the certificate.