Learn how machine learning models make mistakes, how underfitting and overfitting occur, and how professional data scientists evaluate models.
Start Learning Explore MetricsOverall Correctness
Correct Positives
Find All Positives
Balanced Metric
Topics Covered in this Module
Understand actual values, predicted values, and model mistakes.
Wrong assumptions causing underfitting.
Learning noise and overfitting.
Model too simple.
Model too complex.
Find the optimal model.
Every Machine Learning model makes mistakes. These mistakes are called Errors.
Error is the difference between the Actual Value and the Predicted Value.
| Actual Marks | Predicted Marks | Error |
|---|---|---|
| 80 | 75 | 5 |
| 90 | 85 | 5 |
| 70 | 78 | -8 |
Bias occurs when the model is too simple and makes wrong assumptions.
Bias is the error caused by incorrect assumptions in the learning algorithm.
A student studies only one chapter and assumes:
Exam contains questions from many chapters.
Model fails to learn patterns from training data.
y = x² Using Linear Regression y = mx + c
Straight line cannot fit a curve.
Variance occurs when the model learns noise and memorizes data.
Variance occurs when a model becomes too complex.
Student memorizes all homework answers.
Exam contains new questions.
Model memorizes training data instead of learning patterns.
Decision Tree Depth = 50
Model memorizes every record.
| Feature | Bias | Variance |
|---|---|---|
| Meaning | Wrong Assumptions | Learning Noise |
| Problem | Underfitting | Overfitting |
| Model | Too Simple | Too Complex |
| Training Error | High | Low |
| Testing Error | High | High |
| Example | Linear Regression on Curve | Deep Decision Tree |
Difference between Actual and Predicted Value
Too Simple → Underfitting
Too Complex → Overfitting
Learn Pattern, Not Noise
The Dartboard Analogy is one of the easiest ways to understand Bias and Variance.
Predictions are grouped together but far from the target.
Predictions are spread everywhere.
Predictions are close to actual value.
Accurate and Consistent Predictions.
Understanding how complexity affects learning.
Finding the Sweet Spot Between Underfitting and Overfitting
Dataset: y = x²
Linear Regression can only draw a straight line.
Tree Depth = 50
Memorizes every record.
Curve passes through every point.
Captures actual trend.
The foundation of Classification Evaluation Metrics
| Predicted Positive | Predicted Negative | |
|---|---|---|
| Actual Positive |
TP (True Positive) |
FN (False Negative) |
| Actual Negative |
FP (False Positive) |
TN (True Negative) |
Actual Positive and Predicted Positive.
Cancer Patient correctly detected.
Actual Negative and Predicted Negative.
Healthy Person correctly identified.
Actual Negative but Predicted Positive.
Healthy Person wrongly classified as Cancer.
Actual Positive but Predicted Negative.
Cancer Patient missed by model.
Percentage of total correct predictions.
TP = 40 TN = 35 FP = 10 FN = 15
Spam Email Example: Out of 100 emails predicted as spam, 80 were actually spam.
Cancer Detection Example 100 Cancer Patients Model Finds 90
Used when classes are imbalanced.
| AUC | Performance |
|---|---|
| 1.0 | Perfect |
| 0.9+ | Excellent |
| 0.8+ | Good |
| 0.7+ | Fair |
| 0.5 | Random Guess |
Used when the target variable is continuous (numbers).
Average Error
Squared Error
Root Error
Model Fit
Average of absolute prediction errors.
Example: Actual = [100,120,150] Predicted = [90,125,145] Errors = [10,5,5] MAE = (10+5+5)/3 MAE = 6.67
On average, the model is making an error of 6.67 units.
Squares the error before averaging.
Errors = [10,5,5] Squared Errors 100,25,25 MSE = 150 / 3 MSE = 50
Square root of MSE.
RMSE = √50 RMSE = 7.07
Measures how well the model explains variance in the data.
Example: R² = 0.92
| R² | Meaning |
|---|---|
| 1.0 | Perfect |
| 0.9+ | Excellent |
| 0.8+ | Good |
| 0.5+ | Average |
| 0 | No Learning |
| < 0 | Worse than Guessing |
Enter Actual and Predicted values separated by commas.
| Feature | Classification | Regression |
|---|---|---|
| Output | Category | Numeric Value |
| Example | Pass / Fail | Salary Prediction |
| Metrics | Accuracy, Precision, Recall | MAE, MSE, RMSE, R² |
| Algorithms | Logistic Regression, SVM | Linear Regression |
Classification
Classification
Classification
Classification
Classification
Regression
Regression
Regression