Ravindra BagaleCourses & study guides मराठी Track your progress

37. How to Check If Your ML Model Is Good

Data Science

37.1 Accuracy in Plain English

Why. “My model is 99% accurate” can still be useless. You need plain-English metrics.

What. Accuracy = share of rows where prediction equals the true label. Great when classes are balanced and mistakes cost the same. Weak when 99% of rows are “not fraud.”

How.

Compute accuracy by hand once

  1. List true labels and predictions for 10 rows.
  2. Count matches / 10.
  3. Ask: is the majority class 90%+? Then accuracy alone may lie.
from sklearn.metrics import accuracy_score
y_true = [0, 0, 0, 0, 0, 0, 0, 0, 1, 1]
y_pred = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0] # always predict 0
print("accuracy:", accuracy_score(y_true, y_pred))
print("Looks high, but both fraud cases were missed.")

Ravindra Bagale's Tip

Before you feel happy about a high accuracy, check the class balance, which means how many rows belong to each class. If one class is much bigger than the others, accuracy can mislead you, so look at precision and recall too.