Skip to content
Tutorials Center
My learning

Topics

Machine Learning Tutorial

Learn Machine Learning step by step: 111 lessons in 12 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 What Is Machine Learning? Learn what machine learning is, how it differs from rules and statistics, the main learning types, key terms like features and labels, and when not to use it.
  2. 2 Applications of Machine Learning See where machine learning is used in healthcare, finance, e-commerce, transport, manufacturing, security and farming, plus pattern recognition and challenges.
  3. 3 The Machine Learning Workflow Walk through the full machine learning workflow: framing the problem, data, split, baseline, training, evaluation, iteration and deployment, with a first model.
  4. 4 The scikit-learn API Understand scikit-learn's estimator API: fit, predict, transform and score, hyperparameters versus learned attributes, get_params, set_params and clone.
  5. 5 Working with Datasets Load scikit-learn toy datasets, generate synthetic data with make_classification, make_regression, make_blobs and make_moons, and convert pandas to arrays.
  6. 6 Exploratory Data Analysis for Machine Learning Learn EDA step by step: check shape, types and missing values, then run univariate, bivariate and multivariate analysis with pandas, correlations and plots before modeling.
  7. 7 Train, Validation and Test Sets Learn why we split data into train, validation and test sets, how to use train_test_split with random_state and stratify, and how data leakage ruins results.
  8. 8 Baselines and Dummy Models Learn why every machine learning project needs a baseline, how DummyClassifier and DummyRegressor work, and how to beat a baseline honestly.
  9. 9 Math for Machine Learning - Linear Algebra and Calculus Learn the math behind machine learning in NumPy: vectors, dot products, matrices, least squares, eigenvectors, derivatives, gradients and the chain rule.
  10. 10 Multivariable Calculus for Machine Learning Partial derivatives, the gradient, the Hessian, Newton and quasi-Newton methods, and Lagrange multipliers, explained with short numerical examples for ML.
  11. 11 Probability and Statistics for Machine Learning Learn the probability behind machine learning: distributions, Bayes rule, maximum likelihood, the central limit theorem and the bootstrap, with NumPy and SciPy.
  12. 12 Density Estimation and Maximum Likelihood Estimate a probability distribution from data: maximum likelihood for parametric models, histograms and kernel density estimation for non-parametric ones.

Regression

  1. 13 Linear Regression Learn how linear regression fits a line by least squares, how to read the slope and intercept, and how to use LinearRegression to predict and plot results.
  2. 14 Multiple Linear Regression Predict from many features at once: read coefficients correctly, spot multicollinearity, see why scaling changes interpretation, and compare with statsmodels.
  3. 15 Regression Metrics Measure a regression model honestly with MAE, MSE, RMSE, R squared, adjusted R squared and MAPE, read residual plots, and choose the metric that fits your problem.
  4. 16 Gradient Descent from Scratch Build gradient descent in NumPy: loss, gradient, learning rate, batch, stochastic and mini-batch updates, convergence plots, and scikit-learn's SGDRegressor.
  5. 17 Optimizers: Momentum, RMSprop and Adam Compare gradient descent with momentum, Nesterov, Adagrad, RMSprop and Adam in NumPy, and learn gradient clipping, weight decay and how to pick an optimizer.
  6. 18 Polynomial Regression and Nonlinearity Fit curves with linear models: PolynomialFeatures, choosing the degree, a first look at underfitting and overfitting, and interaction terms between features.
  7. 19 Ridge, Lasso and Elastic Net Stop overfitting with penalized regression: how Ridge and Lasso shrink coefficients, how alpha works, why Lasso selects features, and how to tune with RidgeCV and LassoCV.

Classification

  1. 20 Logistic Regression Learn how logistic regression turns a straight-line score into a probability with the sigmoid, how to read its coefficients as log-odds, and how C controls regularization.
  2. 21 Classification Metrics Why accuracy misleads, how to read a confusion matrix, and how precision, recall, specificity and F1 describe a classifier, with runnable scikit-learn examples.
  3. 22 Thresholds, ROC and Precision-Recall Curves Move beyond 0.5: use predict_proba, decision thresholds, ROC and AUC, precision-recall curves and average precision, and pick a threshold by cost.
  4. 23 k-Nearest Neighbors Learn how k-nearest neighbors predicts from the closest training points: choosing k, distance metrics, why scaling matters, the curse of dimensionality and speed.
  5. 24 Naive Bayes Understand Bayes' rule and the naive independence assumption, then use GaussianNB, MultinomialNB and BernoulliNB, including a small text-count example.
  6. 25 Multiclass and Multilabel Classification Handle more than two classes or several labels per sample: one-vs-rest, one-vs-one, softmax, macro, micro and weighted averages, and MultiOutputClassifier.
  7. 26 Imbalanced Classes Learn what to do when one class is rare: why accuracy lies, class_weight, undersampling and oversampling by hand, stratified splits, PR metrics and costs.

Trees and Ensembles

  1. 27 Decision Trees Learn how decision trees split data using Gini impurity and entropy, compute information gain by hand, fit DecisionTreeClassifier, and read the tree as rules.
  2. 28 Controlling Tree Complexity Stop decision trees from memorizing noise: tune max_depth and min_samples_leaf, prune with ccp_alpha, see regression trees as stairs, and why trees vary.
  3. 29 Random Forests Understand random forests: bootstrap sampling, feature subsampling, voting, out-of-bag score, n_estimators, max_features, feature importances, and regression.
  4. 30 Bagging, Extra Trees and Voting Learn BaggingClassifier, ExtraTreesClassifier and VotingClassifier with hard and soft voting, and see the bias-variance effect of averaging in a simulation.
  5. 31 Gradient Boosting Understand gradient boosting by building it by hand: fit residuals with small trees, balance learning rate and trees, use subsample and early stopping.
  6. 32 AdaBoost and Boosting from Scratch Understand AdaBoost by building it: reweight samples, train decision stumps, combine them with weights, then use scikit-learn's AdaBoostClassifier and AdaBoostRegressor.
  7. 33 Histogram Gradient Boosting Use HistGradientBoostingClassifier and Regressor: binned features for speed, native missing values and categories, early stopping, and how it compares with XGBoost and LightGBM.
  8. 34 XGBoost, LightGBM and CatBoost What XGBoost, LightGBM and CatBoost share: shrinkage, histogram bins, leaf-wise trees, early stopping and categorical handling, demonstrated with scikit-learn.
  9. 35 Stacking and Blending Models Combine different models with StackingClassifier and StackingRegressor: how a meta-learner works, why cross-fitted predictions matter, and when ensembles are worth the cost.
  10. 36 Feature Importance and Interpretation Find out which features a model uses: impurity importance and its pitfalls, permutation importance, partial dependence and ICE plots, and why correlated features fool them.

Support Vector Machines and Other Models

  1. 37 Support Vector Machines Learn how a support vector machine finds the widest margin between classes: support vectors, the C parameter, hinge loss, feature scaling and decision_function in scikit-learn.
  2. 38 Kernels and Nonlinear SVMs Learn the kernel trick behind nonlinear SVMs: RBF and polynomial kernels, how gamma and C interact, boundary plots, support vector regression and scalability limits.
  3. 39 Linear Models with SGD Train linear classifiers with stochastic gradient descent: SGDClassifier losses, partial_fit for online learning, learning rate schedules, large-data use and the Perceptron.
  4. 40 Discriminant Analysis Learn linear and quadratic discriminant analysis in scikit-learn. Compare shared and per-class covariance, use LDA to reduce dimensions, and compare it with logistic regression.
  5. 41 Gaussian Processes, Neural Nets and Choosing a Model Fit a Gaussian process that reports its own uncertainty, train a small neural network with MLPClassifier, and learn a practical way to choose a model for your data.

Model Evaluation and Tuning

  1. 42 Loss Functions and Cross-Entropy What a loss function is, and how MSE, MAE, Huber, hinge, log loss, categorical and sparse categorical cross-entropy compare, with NumPy code you can run.
  2. 43 Overfitting, Underfitting and Bias-Variance Understand why models fail on new data. Compare training and test error, see the bias-variance tradeoff in a NumPy simulation, and diagnose problems from scores.
  3. 44 Cross-Validation Estimate model performance reliably with k-fold, stratified and repeated cross-validation. Use cross_val_score and cross_validate, and see how much a single split can mislead.
  4. 45 Cross-Validation for Groups and Time Standard k-fold fails when rows are related. Learn GroupKFold for repeated subjects, TimeSeriesSplit for ordered data, and how duplicates and groups cause leakage.
  5. 46 Learning and Validation Curves Use learning_curve and validation_curve to see whether you need more data or a different model. Learn to read the curves, spot gaps and plateaus, and plot them.
  6. 47 Hyperparameter Tuning Tune models with GridSearchCV, RandomizedSearchCV and successive halving: build parameter grids, sample from distributions, read cv_results_ and stay within a time budget.
  7. 48 Nested Cross-Validation and Data Leakage See why a tuned model's best score is optimistic, measure the bias with nested cross-validation, and learn to spot target leakage, preprocessing leakage and duplicate rows.
  8. 49 Probability Calibration and Uncertainty Check whether predicted probabilities can be trusted with reliability curves, Brier score and log loss, fix them with CalibratedClassifierCV, and build prediction intervals.

Feature Engineering and Pipelines

  1. 50 Scaling and Normalization Learn when and how to scale features with StandardScaler, MinMaxScaler, RobustScaler, Normalizer and PowerTransformer, which models need it, and why you fit on train only.
  2. 51 Encoding Categorical Features Turn categories into numbers with OneHotEncoder, OrdinalEncoder and TargetEncoder, handle unknown and rare categories, and cope with high-cardinality columns safely.
  3. 52 Handling Missing Data Deal with missing values using SimpleImputer, KNNImputer and IterativeImputer, add missing indicators, understand MCAR, MAR and MNAR, and use models that accept NaN.
  4. 53 Outliers with Z-Scores and the IQR Rule Find and handle outliers before modeling: point, contextual and collective types, z-score, modified z-score and IQR rules, capping, dropping and robust models.
  5. 54 Feature Creation and Transformation Create better model inputs: ratios, interactions, log transforms, binning with KBinsDiscretizer, date and cyclic features, FunctionTransformer and splines.
  6. 55 Feature Extraction from Signals and Images Turn raw signals and images into compact features: summary statistics, Fourier and wavelet features, HOG for images, and extraction versus selection.
  7. 56 Text Features Turn text into numbers for machine learning: CountVectorizer, TfidfVectorizer, n-grams, sparse matrices, the hashing trick and a small text classifier.
  8. 57 Feature Selection Choose which features to keep: VarianceThreshold, SelectKBest, RFE, SelectFromModel and L1 selection, and how to select inside cross-validation without leakage.
  9. 58 Pipelines Chain preprocessing and a model into one scikit-learn Pipeline: step names, parameter routing, use in cross-validation and grid search, leakage and caching.
  10. 59 ColumnTransformer and Mixed Data Apply different preprocessing to numeric and categorical columns with ColumnTransformer: selectors, remainder, pandas output, feature names and a full pipeline.
  11. 60 Custom Transformers and Estimators Write your own scikit-learn transformer and classifier with BaseEstimator and the mixins: the fit/transform contract, get_params rules and contract tests.

Unsupervised Learning

  1. 61 Clustering Basics Learn what clustering is, how similarity and feature scaling shape the groups, and how k-means, agglomerative and DBSCAN compare on blobs and moons.
  2. 62 k-Means Clustering Understand the k-means algorithm step by step, build it in NumPy, pick k with the elbow method and silhouette score, and learn where k-means fails.
  3. 63 Hierarchical Clustering Learn agglomerative clustering: how linkage types differ, how to read and cut a SciPy dendrogram, and how connectivity constraints change the result.
  4. 64 More Clustering Algorithms Go beyond k-means: mean-shift finds the cluster count itself, k-medoids resists outliers, divisive clustering splits top-down, k-modes handles categories.
  5. 65 DBSCAN, HDBSCAN and Density Clustering Cluster by density with DBSCAN, choose eps and min_samples with a k-distance plot, label noise, and use HDBSCAN and OPTICS for varying-density data.
  6. 66 Gaussian Mixture Models Learn Gaussian mixture models: soft cluster membership, the EM algorithm in plain terms, covariance types, choosing components with BIC and AIC, and density estimation.
  7. 67 Evaluating Clusters Evaluate clusters with and without labels: silhouette, Davies-Bouldin, Calinski-Harabasz, adjusted Rand index, stability by resampling and cluster profiles.
  8. 68 Principal Component Analysis Learn principal component analysis: find directions of maximum variance, read explained_variance_ratio_, choose components, whiten, reconstruct, and build PCA from SVD.
  9. 69 t-SNE and Manifold Learning Visualize high-dimensional data with t-SNE and Isomap, learn what perplexity does, why t-SNE plots mislead, and how to check an embedding with trustworthiness.
  10. 70 Other Dimensionality Reduction Go beyond PCA: TruncatedSVD for sparse text, NMF for parts-based topics, kernel PCA, random projections, factor analysis and ICA, with runnable scikit-learn examples.
  11. 71 Anomaly and Outlier Detection Find unusual points with IsolationForest, LocalOutlierFactor, OneClassSVM and EllipticEnvelope, understand contamination, and evaluate detectors when you have no labels.
  12. 72 Association Rule Mining and the Apriori Algorithm Find items bought together: itemsets, support, confidence and lift, with the Apriori algorithm written from scratch in plain Python on a basket dataset.

Beyond the Basics

  1. 73 Recommendation Basics Build a recommender from scratch: user-item matrices, similarity-based collaborative filtering, matrix factorization with SVD and NMF, cold start, and honest evaluation.
  2. 74 Machine Learning for Time Series Turn forecasting into regression: lag and rolling features, seasonality features, naive and seasonal-naive baselines, and walk-forward evaluation with scikit-learn.
  3. 75 Stationarity Tests and Exponential Smoothing Test a series for stationarity with ADF and KPSS, find its seasonal period, stabilize its variance and forecast with Holt-Winters exponential smoothing.
  4. 76 Semi-Supervised Learning and Active Learning Learn when labels are scarce: self-training, label propagation, and an uncertainty-sampling active learning loop that spends a labeling budget wisely.
  5. 77 Saving Models and Deploying Save a trained model with joblib, understand pickle's security risks, avoid training/serving skew, serve predictions from a function, and monitor drift with PSI and KS.
  6. 78 Serving Models with Flask and Render Wrap a scikit-learn model in a Flask API with validation, test it, package it with gunicorn and requirements, and deploy it to a cloud host such as Render.
  7. 79 Model Demos with Streamlit and Gradio Wrap a scikit-learn model in a web UI with Streamlit or Gradio: design the prediction function, cache the model, guard the inputs, and share the demo.
  8. 80 Experiment Tracking with MLflow Learn why every ML run should log its parameters, metrics and artifacts, how MLflow tracking and the model registry work, and build a mini tracker in Python.
  9. 81 MLOps and Model Monitoring Run models in production: the MLOps lifecycle, serving patterns, drift and performance monitoring with delayed labels, and when to retrain, in runnable Python.
  10. 82 CI/CD for Machine Learning Automate tests, data validation, training, evaluation gates and deployment for ML: a GitHub Actions workflow, drift checks and a champion-challenger gate.
  11. 83 AutoML Explained See what AutoML automates, build a mini AutoML loop with random search over pipelines plus an ensemble, and learn when to trust or avoid automated tools.
  12. 84 Fairness, Bias and Responsible ML See how sampling bias, label bias and proxy features create unfair models, measure group metrics by hand, weigh the trade-offs and document and protect your data.
  13. 85 Common Machine Learning Mistakes Learn the mistakes that sink real projects: data leakage, wrong metrics, tuning on the test set, missing baselines, drift over time, tiny datasets and unseeded runs.
  14. 86 Self-Supervised Learning Learn from unlabeled data: pretext tasks, masked prediction and contrastive learning, with a runnable scikit-learn demo and an InfoNCE loss in NumPy.
  15. 87 Hidden Markov Models Learn hidden Markov models with runnable NumPy code: Markov chains, the forward algorithm, Viterbi decoding and Baum-Welch training on a small weather example.

Reinforcement Learning

  1. 88 Reinforcement Learning Basics Learn reinforcement learning from first principles: agents, rewards, MDPs, policies, discounting and exploration vs exploitation, with a NumPy bandit.
  2. 89 Q-Learning, SARSA and Model-Free Methods Compare Q-learning and SARSA on the cliff-walking gridworld, learn what on-policy and off-policy mean, and see how Monte Carlo and TD learning differ.
  3. 90 Policy Gradients, REINFORCE and Actor-Critic Learn policy-based reinforcement learning: the policy gradient idea, REINFORCE with a baseline, and a one-step actor-critic, all built in NumPy on a small grid.

Projects

  1. 91 Project: Predicting House Prices Build a complete regression project: explore synthetic housing data, make a preprocessing pipeline, compare linear, regularized and boosted models and analyze the errors.
  2. 92 Project: Customer Churn Classifier Build a churn classifier on imbalanced tabular data: ColumnTransformer pipeline, cost-based decision threshold, probability calibration and feature importances.
  3. 93 Project: Box Office Revenue Prediction Predict movie revenue with regression: tame a skewed target with logs, encode ratings and genres, compare models in dollars and percent, give forecast ranges.
  4. 94 Project: Spam Filter Build a spam filter in Python: generate a small message corpus, turn text into TF-IDF features, compare Naive Bayes and logistic regression, and tune the threshold.
  5. 95 Project: Handwritten Digit Recognizer Build a handwritten digit classifier with scikit-learn: compare SVM, random forest and neural network, read the confusion matrix, and speed up training with PCA.
  6. 96 Project: Customer Segmentation Segment customers with machine learning: build RFM features, fix skew and scale, choose k with several metrics, compare k-means with a Gaussian mixture, and name the segments.
  7. 97 Project: Click-Through Rate Prediction Predict ad clicks from high-cardinality categories: one-hot, the hashing trick, target encoding, log loss versus AUC, and calibration of predicted click rates.
  8. 98 Project: Credit Risk Scoring Build a credit default model end to end: audit for target leakage, add monotonic constraints to gradient boosting, calibrate probabilities, and check fairness by group.
  9. 99 Project: Loan Approval Prediction Predict loan approvals from mixed applicant data with missing values: pipelines, engineered ratios, repeated cross-validation, costs and explanations.
  10. 100 Project: Credit Card Fraud Detection Build a fraud detector on imbalanced transactions: see the accuracy trap, compare class weights, under-sampling and SMOTE, and choose a threshold by cost.
  11. 101 Project: Fake News and SMS Spam Detection Two text classification projects in one: detect SMS spam and fake news with TF-IDF and linear models, handle disguised words, and catch a source leak that fools the score.
  12. 102 Project: Sales and Demand Forecasting Forecast daily sales with scikit-learn: build lag and calendar features, validate with time-ordered splits, avoid leakage, and compare baselines, direct and recursive forecasts.
  13. 103 Project: Stock and Crypto Price Prediction Predict stock or crypto direction on a time series: why price R2 is a trap, walk-forward validation, look-ahead leakage and a backtest with trading costs.
  14. 104 Project: Heart Disease and Breast Cancer Diagnosis Two diagnosis projects with scikit-learn: breast cancer cell measurements and a heart-disease table. Compare logistic regression and kNN with cross-validation and tune for recall.
  15. 105 Project: Movie Recommender Build a movie recommender end to end with NumPy and pandas: bias baselines, genre profiles, item-item filtering, matrix factorization, ranking metrics and cold start.
  16. 106 Project: Titanic Survival The classic first ML project, end to end: explore a passenger table, handle missing ages and cabins, engineer features, compare models with CV and read the result.

Practice and Review

  1. 107 Exercises: Workflow, Regression and Classification Ten graded scikit-learn exercises with full solutions: splits, baselines, linear regression, metrics, imbalanced classification, thresholds and feature scaling.
  2. 108 Exercises: Ensembles, Pipelines and Unsupervised Ten advanced scikit-learn exercises with full solutions: random forests, boosting, stacking, pipelines, leakage, grid search, k-means clustering and PCA.
  3. 109 Machine Learning Interview Questions Prepare for machine learning interviews: bias-variance, regularization, metrics, data leakage, trees vs boosting and the curse of dimensionality, each with a short runnable proof.
  4. 110 ML Coding Interview Questions Practice the machine learning coding interview: implement metrics, AUC, scalers, kNN, k-means, linear and logistic regression from scratch in NumPy and check them against scikit-learn.
  5. 111 Machine Learning Cheat Sheet A one-page machine learning cheat sheet: choose a model and metric, copy scikit-learn snippets and a pipeline template, and check your work against a pitfalls list.