Topics / 🤖 AI & Machine Learning / 🤖 Level 21: First ML Models

Python exercise · about 5 minutes · free

Always Start with a Baseline

A model that always says 'no default' is 91% accurate here, and completely useless. Baselines keep you honest.

DummyClassifier(strategy="most_frequent") always predicts the most common class. If your real model can't clearly beat it, it isn't learning anything useful. Also check recall: how many real defaults did it catch?

Accuracy says: 91% correct!, (by always predicting 'no default'). Recall says: 0 of 9 defaults caught, the model is useless✗ Accuracy says91% correct!(by always predicting 'no default')✓ Recall says0 of 9 defaults caughtthe model is useless
Your quest: Fit the dummy model, then set acc (accuracy) and rec (recall for defaults).
Try it now Runs in your browser. No sign-in needed. Ctrl+Enter to run.
Hintm = DummyClassifier(strategy="most_frequent").fit(X, y); p = m.predict(X); acc = accuracy_score(y, p); rec = recall_score(y, p)
Output appears here.

Open it in the full course → Free with Google: saves your progress and unlocks 627 lessons.

In this level you'll learn:
More in Level 21: First ML Models

Share on LinkedIn