Phase 02: ML Fundamentals

Model Evaluation

A model is only as good as the way you measure it. Implement K-fold and stratified K-fold cross-validation from scratch and explain why stratification matters for imbalanced data. Compute precision, recall, F1, AUC-ROC, and regression metrics (MSE, RMSE, MAE, R-squared) from scratch. Interpret learning curves to diagnose whether a model suffers from high bias or high variance. Identify common evaluation mistakes including data leakage, wrong metric selection, and test set contamination. You trained a model. It gets 95% accuracy on your data. Is it good? Maybe. Maybe not. If 95% of your data belongs to one class, a model that always predicts that class gets 95% accuracy while being completely useless. If you evaluated on the same data you trained on, the 95% number is meaningless because the model just memorized the answers. If your dataset has a time component and you randomly shuffled before splitting, your model might be using future data to predict the past. Model evaluation is where most ML projects go wrong. The wrong metric makes a bad model look good. The wrong split lets a model cheat. The wrong comparison makes you pick the worse model. Getting evaluation right is not optional. It is the difference between a model that works in production and one that fails the moment it sees real data. Three splits,…

Model Evaluation: A model is only as good as the way you measure it. Implement K-fold and stratified K-fold cross-validation from scratch and explain why…

This free lesson is part of the AI Engineering from Scratch curriculum. Read the full explanation, run the lesson code, and verify the result in the interactive reader or from the repository source.

Browse the complete course catalog or open this lesson on GitHub.