R
Rishtaara
Machine Learning Fundamentals
Lesson 5 of 8Article20 min

Classification Models

Classification Models

Classification tasks

  • Spam detection, fraud screening, churn prediction.
  • Binary, multiclass, and multilabel formulations.
  • Threshold choice affects precision/recall trade-offs.

Logistic regression classifier

Train and probability thresholding
from sklearn.linear_model import LogisticRegression
from sklearn.metrics import classification_report

clf = LogisticRegression(max_iter=1000)
clf.fit(X_train, y_train)

proba = clf.predict_proba(X_test)[:, 1]
pred = (proba >= 0.6).astype(int)  # custom threshold
print(classification_report(y_test, pred))