✦ New Age Learning 🔍
Home › Library › AI for New Learner- Senior 2 › Chapter 6: Evaluation — Does It Actually Work?

📖 Chapter 6 of 13 · AI for New Learner- Senior 2 · Class 10

Chapter 6: Evaluation — Does It Actually Work?

In this chapter

  • Mira from Chandigarh catches a data leakage bug.
  • Why 99% accuracy can be 0% useful.
  • Precision, recall, F1 — when each one matters.
  • The confusion matrix — every ML engineer’s best friend.
  • Real failure case: an AI loan model that rejected the wrong people.
  • How to write a Model Card (what professionals do).

The Big Idea

Anyone can train a model. The hard skill is knowing whether it WORKS — and where it FAILS. A cancer-detection AI with 99% accuracy is useless if it misses 1 in 4 actual cancers. This is where junior engineers separate from senior ones. By the end of this chapter, you will evaluate models the way a senior engineer at Niramai or NPCI does.

Did you know?

In 2016, an AI screening tool used by a US hospital was 99% accurate at detecting one disease — but missed 50% of cases in dark-skinned patients. The training data was biased. Evaluation by sub-group is now a legal requirement in many AI deployments.

Builder Profile: Mira

Chandigarh · age 15

Mira reads a confusion matrix to expose a model whose 96% accuracy hid a costly data-leakage bug.

Mira interned with a Chandigarh startup that built a heart-attack-risk AI for clinics. The model showed 96% accuracy on internal tests. The founder was ecstatic. Mira looked closer.

She noticed something odd: the model used ‘time of day patient arrived’ as a feature. In the training data, severe cases came in at night. The model had learned: “midnight admission = high risk”. That is DATA LEAKAGE — the model was reading the answer indirectly from a feature that shouldn’t matter.

She rebuilt the evaluation. Real accuracy on fresh patients: 71%. The startup almost shipped a dangerous tool. Mira’s catch saved the company from a public scandal. Now she has a job offer for after her boards — at a Bengaluru AI safety company.

The confusion matrix

Every metric you need is hidden in one 2×2 grid. For a spam classifier, the four cells are: True Positive (spam correctly caught), False Negative (spam missed — it slipped through), False Positive (real mail wrongly blocked), and True Negative (real mail correctly delivered). Reading this grid is how you spot exactly where a model fails.

Mira reads a confusion matrix to expose a model whose 96% accuracy hid a costly data-leakage bug.

⊕ MATH MINUTE Precision, Recall, F1

PRECISION: of all things I called spam, how many actually were? Use when FALSE POSITIVES hurt (blocking real mail). RECALL: of all real spam, how many did I catch? Use when FALSE NEGATIVES hurt (cancer detection). F1: the harmonic mean of both — when you care about both equally.

Precision = TP/(TP+FP) • Recall = TP/(TP+FN) • F1 = 2PR/(P+R)

💻 CODE LAB Full Evaluation in One Block

from sklearn.metrics import (accuracy_score, precision_score,
    recall_score, f1_score, confusion_matrix, classification_report)

# y_true: real labels   y_pred: model predictions
print('Accuracy: ', accuracy_score(y_true, y_pred))
print('Precision:', precision_score(y_true, y_pred))
print('Recall:   ', recall_score(y_true, y_pred))
print('F1:       ', f1_score(y_true, y_pred))

print('Confusion matrix:')
print(confusion_matrix(y_true, y_pred))

# The professional shortcut:
print(classification_report(y_true, y_pred))
# Prints precision, recall, f1 for every class at once

⚠ FAILURE ANALYSIS

Problem: 99% accuracy but a useless cancer screener.

Why: Out of 1000 patients, 990 are healthy and 10 have cancer. The model predicts ‘healthy’ for EVERYONE. Accuracy = 990/1000 = 99%. But it caught 0/10 actual cancers — recall = 0%.

Fix: Use the right metric for the problem. For rare-event detection (cancer, fraud), RECALL matters more than accuracy. Also use stratified sampling, class weights, and the F1-score.

Solved illustrations

1. Why is accuracy a bad metric for cancer detection?

Show answer

Answer: If only 1% of patients have cancer, a model predicting ‘no cancer’ for everyone gets 99% accuracy but catches ZERO real cases. Use recall instead.

2. What is data leakage? Give one example.

Show answer

Answer: When information about the target variable accidentally appears in the features. Example: in Mira’s heart-risk model, ‘time of admission’ leaked the severity. Catching this matters more than the headline metric.

3. When is precision more important than recall?

Show answer

Answer: When false positives are costly. Spam filter: it is worse to block one important email (FP) than to miss one spam (FN). Use precision.

4. When is recall more important?

Show answer

Answer: When false negatives are costly. Cancer screening: missing one real cancer (FN) is far worse than scheduling one unnecessary follow-up (FP). Use recall.

5. What is a Model Card?

Show answer

Answer: A short document any ML team should write for every shipped model. It states: who the model is for, what data it was trained on, performance by sub-group, known failures, and last update date. Google, Hugging Face, and IndiaAI all require model cards.

Evaluation — your new habits

Before you ship ANY model, check all six: (1) train/test split done correctly, with the test set never seen during training and a fixed random seed; (2) the right metric for the problem — recall for cancer/fraud, precision for spam, F1 when both matter, not just accuracy; (3) evaluated by sub-group (gender, age, region), fixing any group that underperforms before shipping; (4) confusion matrix examined, with every false positive and negative understood; (5) failure cases documented; (6) a model card written with who built it, when, on what data, the performance numbers, and known limitations.

Questions — Chapter 6

  1. Write the formulas for precision and recall.
  2. Give one example of an Indian AI where high recall matters more than precision.
  3. What 4 things must every model card contain?
  4. Train any sklearn model and print its classification_report.
  5. Explain data leakage using Mira’s story in your own words.

Ship-It Challenge

Take any model from Ch 3-5. Write a 1-page Model Card. Share it on GitHub.

Check your understanding — Chapter 6

Tap an answer to check it instantly. These are for practice — nothing is saved or sent.

Q1. Why is accuracy a bad metric for cancer detection?

  1. Accuracy is always bad
  2. If only 1% of patients have cancer, a model predicting 'no cancer' for everyone gets 99% accuracy but catches ZERO real cases
  3. Cancer can't be detected by AI
Show answer

B. If only 1% of patients have cancer, a model predicting 'no cancer' for everyone gets 99% accuracy but catches ZERO real cases

Q2. What is data leakage?

  1. A broken hard drive
  2. When information about the target accidentally appears in the features — like 'time of admission' leaking severity in Mira's heart-risk model
  3. When data is deleted
Show answer

B. When information about the target accidentally appears in the features — like 'time of admission' leaking severity in Mira's heart-risk model

Q3. When is recall more important than precision?

  1. Never
  2. When false negatives are costly — e.g. missing a real cancer is far worse than one unnecessary follow-up
  3. Only for spam
Show answer

B. When false negatives are costly — e.g. missing a real cancer is far worse than one unnecessary follow-up

Q4. What is a Model Card?

  1. A playing card
  2. A short document stating who the model is for, its training data, performance by sub-group, known failures and last update
  3. A type of GPU
Show answer

B. A short document stating who the model is for, its training data, performance by sub-group, known failures and last update

All chapters in AI for New Learner- Senior 2

  1. Chapter 1: Where You Are Now — The ML Lifecycle
  2. Chapter 2: From Idea to Dataset
  3. Chapter 3: Linear Models — The Workhorses
  4. Chapter 4: Decision Trees & Random Forests
  5. Chapter 5: Neural Networks Demystified
  6. Chapter 6: Evaluation — Does It Actually Work?
  7. Chapter 7: Indian Datasets & Real Problems
  8. Chapter 8: Deploy Your AI — Get a Public URL
  9. Capstone Build-It Projects
  10. Final Book Exam
  11. AI / ML / Python Glossary
  12. Career & College Pathways
  13. Series Completion Diploma

Practise for Class 10