Machine Learning
End-to-end ML workflow with scikit-learn, XGBoost, LightGBM, and the honest engineering practices that prevent silent failures in production.
- Chapter 01
Foundations
6 lessons - 01 What ML actually is Cut through the hype. Here's what machine learning is, what it isn't, and where it sits in the modern data stack.
- 02 The scikit-learn API Every scikit-learn estimator follows the same three-method contract. Once you see it, the whole library makes sense.
- 03 Feature engineering & encoding On tabular data the model is a commodity — the features are the edge. Encoding categoricals, scaling numerics, interactions and aggregations, all w…
- 04 Train/val/test & CV Why you never evaluate on training data, how to split properly, and the time-series gotcha that bites everyone once.
- 05 Bias–variance & learning curves The single most useful diagnostic in ML: is your model too simple (bias) or too flexible (variance)? Read the learning curve to decide whether to g…
- 06 Curse of Dimensionality Add features and your data gets exponentially lonelier. In high dimensions everything is far away, distances stop meaning anything, and intuition b…
- Chapter 02
Regression
2 lessons - 07 Linear regression The model that started it all — and is still the right answer more often than people admit.
- 08 L1, L2, Elastic Net Adding many features makes linear models overfit. Regularization is the fix you reach for before reaching for trees.
- Chapter 03
Classification
5 lessons - 09 Logistic regression Despite the name, it's a classifier — and the workhorse classifier in industry. Outputs calibrated probabilities, not just labels.
- 10 K-nearest neighbors The simplest learner there is — no training, just store the data and let a new point's nearest neighbors vote. How k controls the bias-variance tra…
- 11 Naive Bayes Bayes' rule plus one bold assumption — that features are independent — gives a fast, surprisingly strong classifier, especially for text. Why 'naiv…
- 12 Support vector machines Find the boundary with the widest margin between classes — and bend it to any shape with the kernel trick. The max-margin idea, soft margins (C), a…
- 13 Class imbalance When 99% of your rows are one class, "always predict negative" hits 99% accuracy and ships nothing useful. Here's how to actually fix it.
- Chapter 04
Trees & Boosting
5 lessons - 14 Bagging, boosting & stacking Why a committee of models beats any single one. The unifying theory behind random forests and XGBoost — bagging cuts variance, boosting cuts bias,…
- 15 Decision trees The simplest non-linear model — interpretable, requires no scaling, handles mixed types. And the building block of every modern boosting library.
- 16 Random forests Take the high-variance decision tree, train hundreds of them on bootstrapped samples with random feature subsets, and average. That's it — and it w…
- 17 XGBoost, LightGBM, CatBoost Build trees sequentially, each correcting the last one's mistakes. The reason every winning Kaggle solution on tabular data uses XGBoost, LightGBM,…
- 18 SHAP & feature importance Built-in `feature_importances_` is misleading. SHAP decomposes every prediction into per-feature contributions you can actually defend to a regulat…
- Chapter 05
Evaluation
7 lessons - 19 Metrics that matter Accuracy is a trap on imbalanced data. Here's the full crew — precision, recall, F1, ROC-AUC, PR-AUC, log-loss, MAE, RMSE, R² — and when to reach f…
- 20 Data leakage The bug that makes your model look amazing in development and fail in production. Three forms, three fixes. Master the Pipeline pattern.
- 21 Hyperparameter tuning Grid search, random search, Bayesian search with Optuna. The pattern that prevents you from accidentally tuning on the test set.
- 22 Feature selection Fewer features can beat more — less overfitting, faster models, clearer explanations. Filter, wrapper, and embedded methods, plus permutation impor…
- 23 Model selection & nested CV If you tune hyperparameters and report the same CV score, you're lying to yourself. Nested cross-validation separates tuning from evaluation so you…
- 24 Model Calibration When your model says 70%, does the thing happen 70% of the time? A model can rank perfectly (great AUC) and still lie about its probabilities. Cali…
- 25 AutoML in practice Let a tool search models, hyperparameters, and preprocessing for you. What AutoML does well as a baseline and prototyping accelerator — and why it'…
- Chapter 06
Unsupervised
6 lessons - 26 K-means clustering The first unsupervised algorithm — group unlabeled data into k clusters by alternating assign and update. How Lloyd's algorithm works, why init mat…
- 27 DBSCAN & hierarchical When k-means fails on non-blob shapes, density-based and hierarchical clustering succeed. DBSCAN finds arbitrary shapes and outliers with no preset…
- 28 PCA & dimensionality reduction Find the few directions your data actually varies along, and drop the rest. How principal component analysis compresses high-dimensional data while…
- 29 t-SNE & UMAP See the structure in high-dimensional data by projecting it to 2D — the right way. How nonlinear embeddings reveal clusters PCA misses, and the tra…
- 30 Gaussian mixture models Soft clustering — every point gets a probability of belonging to each cluster, not a hard label. How GMMs model data as a mix of Gaussians, fit wit…
- 31 Anomaly detection Find the rare, the fraudulent, the broken — without labels. Isolation Forest, Local Outlier Factor, and one-class methods for spotting points that…
- Chapter 07
Responsible ML
2 lessons - 32 Interpretability: SHAP vs LIME Your model said no. Now explain why. The map of post-hoc interpretability — global vs local, LIME's local surrogate vs SHAP's additive Shapley valu…
- 33 Fairness & bias in ML A model can be accurate overall and still systematically unfair across groups. Where bias comes from, the group-fairness metrics (demographic parit…
- End of section 0 / 33 complete
Make it stick — pass every quiz.
Each lesson has a short quiz at the bottom. Passing the quiz is what marks the lesson complete and counts toward your certificate.
Machine Learning — frequently asked questions
Straight answers to the questions people ask most about machine learning.
Do neural networks always beat traditional ML?
No. On most tabular data, gradient-boosted trees (XGBoost, LightGBM, CatBoost) match or beat neural networks with less tuning and far less data. Deep learning dominates for images, text, and audio, but for structured business data, classical models are usually the stronger and simpler choice.
Read the lessonWhat's the difference between training, validation, and test sets?
You fit the model on the training set, tune hyperparameters on the validation set, and report final performance once on the untouched test set. Keeping the test set truly held out is what makes your reported accuracy honest rather than optimistic.
Why is my model 99% accurate but useless?
Accuracy is misleading on imbalanced data — a model that always predicts the majority class can score 99% while catching none of the rare cases that matter. Use metrics suited to the problem, like precision, recall, F1, or AUC, and read the confusion matrix.
Read the lessonWhat is data leakage and why is it dangerous?
Data leakage is when information unavailable at prediction time sneaks into training — like scaling using the whole dataset before splitting, or a feature derived from the target. It produces great validation scores that collapse in production, making it one of the most costly silent bugs in ML.
Read the lessonWhen should I use XGBoost versus a random forest?
Random forests are robust and need little tuning, so they make a strong baseline. Gradient boosting (XGBoost and friends) usually reaches higher accuracy but is more sensitive to hyperparameters and overfitting. Start with a random forest, then try boosting to squeeze out more performance.