Course map
Stage 1: Foundations
Stage 2: Machine Learning
Stage 3: Deep Learning
Stage 4: LLMs & Generative AI
Stage 5: Production & Specialization

Part 05 / Topic 1 of 7

The scikit-learn API

Every scikit-learn model speaks the same four verbs:

clf = LogisticRegression(max_iter=2000)
clf.fit(X_train, y_train)          # learn
clf.predict(X_test[:3])            # [7 6 3]           class labels
clf.predict_proba(X_test[:3])     # shape (3, 10)     probability per class
clf.score(X_test, y_test)          # 0.958             default metric

(Run on the bundled digits dataset — 1,797 8×8 images, ten classes.) Because the interface is uniform, swapping models is a one-line change. That is what makes the fair comparison in section 7 cheap.

🧪 Quick quiz

  1. Which method returns probabilities instead of labels?
Show the answer

predict_proba — one column per class, rows summing to 1. predict just takes the argmax (at the default threshold for binary tasks).

Done here? The practice set for Part 5 — 4 exercises with solutions — is on the part page.

Search the guide