Model Accuracy & PredictionsConfusion Matrix & Evaluation
Learn how to calculate AI model accuracy, build confusion matrices (TP, TN, FP, FN), and evaluate predictions interactively!
Overview
How do we measure AI success?
After training a Machine Learning model, we measure its real-world performance. The simplest and most common evaluation metric is Accuracy โ the percentage of predictions the model got right out of total attempts.
๐งฎ Interactive Accuracy Calculator
Adjust the total and correct predictions below to see how accuracy updates live:
Accuracy Explained
Spam Filter Case Study
Imagine an AI spam filter tested on 20 new emails. It correctly flags 18 emails and makes 2 errors.
Notice: Accuracy measures overall correctness, but doesn't tell us WHICH types of errors were made (e.g. did it miss spam, or delete your boss's important email?).
โ Quick Practice: If a model correctly predicts 18 out of 20 emails, what is its accuracy?
Confusion Matrix
Breaking Down the 4 Outcomes
To see exactly where predictions go right or wrong, we build a Confusion Matrix with 4 quadrants:
True Positive (TP) โ
Spam email correctly identified and moved to Spam folder.
True Negative (TN) โ
Real email correctly sent to your Inbox.
False Positive (FP) โ (False Alarm)
Real important email falsely marked as Spam!
False Negative (FN) โ (Missed Spam)
Spam email falsely predicted as safe, slipping into Inbox.
| Predicted: SPAM | Predicted: NOT SPAM | |
|---|---|---|
| Actual: SPAM | True Positive (TP) Spam caught! | False Negative (FN) Spam missed! |
| Actual: NOT SPAM | False Positive (FP) Real email blocked! | True Negative (TN) Real email safe! |
Playground: Confusion Matrix Builder
Classify & Track Live Predictions
Classify each email below as Spam or Not Spam to see the 2x2 confusion matrix and accuracy update live!
"Win a free $1000 gift card now!"
"Team meeting tomorrow at 3 PM"
"URGENT: Your bank account is suspended!"
"Dinner with family this weekend?"
"Click here for cheap medicine deals"
"Invoice for your recent book order"
"CONGRATULATIONS you have been selected!"
"Project status report update"
"Double your savings fast"
"Can you review this code snippet?"
Live Confusion Matrix
Interactive Exercises
Exercise 1: Calculate Accuracy
+15 XP ยท BeginnerExercise 2: Identify Error Type 1
+20 XP ยท IntermediateExercise 3: Identify Error Type 2
+25 XP ยท IntermediateExercise 4: The Accuracy Illusion
+30 XP ยท IntermediateKnowledge Check
Ready to test your knowledge?
Answer 10 multiple-choice questions to test your understanding of model accuracy and confusion matrices!
Build Real Machine Learning Models with Tutors
Take the next step! Join our live Intro to Machine Learning Course and write real Python ML code with expert 1-on-1 guidance.