Master data processing, modeling, and deep learning algorithms.
Model evaluation answers a single question: how well does this model actually perform? A model that looks perfect on the data it trained on can fail completely on new data, so evaluation is always about performance on unseen examples and about choosing the right metric for the task. This lesson covers the training/validation/test split, regression metrics (MAE, MSE, RMSE, R²), and classification metrics built from the confusion matrix (accuracy, precision, recall, F1, ROC/AUC). You will calculate metrics step by step on a concrete example. The calculations use pure Python so you can see exactly where each number comes from.
| Metric | What it measures | Notes |
|---|---|---|
| MAE | Average absolute error | Same units as the target |
| MSE | Average squared error | Penalizes large errors heavily |
| RMSE | Square root of MSE | Interpretable, still penalizes big errors |
| R² | Variance explained (0–1) | Higher is better; 0 = predicting the mean |
| Predicted positive | Predicted negative | |
|---|---|---|
| Actual positive | True Positive (TP) | False Negative (FN) |
| Actual negative | False Positive (FP) | True Negative (TN) |
| Goal | Metric |
|---|---|
| Regression error in original units | MAE or RMSE |
| Balanced classes | Accuracy |
| Minimize false alarms | Precision |
| Catch as many positives as possible | Recall |
| Balance precision and recall | F1 |
These formulas are what scikit-learn computes. Pure Python makes each term explicit.
A fraud detector on 1000 transactions (50 real frauds).
(97% accurate, yet it misses 20% of fraud — accuracy hides this)
Three predictions vs actuals.
(on average, predictions are off by 16.7 units)