Machine Learning with scikit-learn

Build, test and explain real ML models in Python: regression, classification, trees, clustering, pipelines, honest metrics and fairness, on Ghanaian examples.

  • 0 students
  • 75 lessons
  • 6 h 24 min

Created by Ayim Nelson

What you will learn

  • Follow the ML workflow: question, data, split, train, evaluate, improve
  • Train and read linear and logistic regression models with scikit-learn
  • Evaluate honestly with test sets and cross-validation, and spot overfitting
  • Prepare features with scaling, encoding, imputation and pipelines, without data leakage
  • Choose metrics such as recall, precision, F1 and ROC AUC, and explain why accuracy misleads
  • Use and tune decision trees, random forests and gradient boosting
  • Find groups with k-means, compress data with PCA and flag anomalies
  • Check a model for bias across groups, explain its predictions and document it in a model card

About this course

Machine learning is how a computer learns a pattern from past examples and uses it to predict new ones. In this course you build models with scikit-learn, the standard Python library for it, on three invented but realistic datasets: trotro fares, mobile money fraud and cocoa farm yields. You learn the full workflow, from splitting the data to choosing a threshold, and how to tell a model that really works from one that only looks good. Every example runs in your browser.

For: learners who know Python, NumPy and pandas, and basic statistics (the Data Analysis with NumPy and pandas and Statistics for Data Science courses). No machine learning experience is needed.

By the end: you'll have trained and tuned linear models, logistic regression, k-NN, trees, forests and gradient boosting; built leak-proof pipelines; judged models with the right metrics; grouped customers with k-means; checked a loan model for fairness; and built an end-to-end fraud detector with a cost-based threshold.

Course content

11 sections · 75 lessons

What machine learning is7 lessons
Linear regression7 lessons
  • A line through pointsReading · 3 min
  • Cost: mean squared errorReading · 3 min
  • Gradient descent by handReading · 4 min
  • LinearRegression in sklearnReading · 3 min
  • Several featuresReading · 3 min
  • Reading coefficientsReading · 3 min
  • Fare model with three featuresExercise · 12 min
Evaluating honestly8 lessons
  • Train/test splitReading · 3 min
  • MAE and RMSEReading · 3 min
  • OverfittingReading · 4 min
  • UnderfittingReading · 3 min
  • Bias and varianceReading · 4 min
  • Validation setReading · 3 min
  • Cross-validationReading · 4 min
  • Cross-validate the fare modelExercise · 12 min
Preparing features9 lessons
  • ScalingReading · 3 min
  • One-hot encodingReading · 3 min
  • Missing values with SimpleImputerReading · 3 min
  • Creating new featuresReading · 4 min
  • PipelinesReading · 4 min
  • ColumnTransformerReading · 4 min
  • Data leakageReading · 4 min
  • Target leakageReading · 3 min
  • Leak-proof pipelineExercise · 15 min
Classification6 lessons
  • Yes/no problemsReading · 3 min
  • Logistic regressionReading · 4 min
  • Probabilities and thresholdsReading · 4 min
  • k-nearest neighboursReading · 3 min
  • Naive Bayes (the scam SMS)Reading · 4 min
  • Flag risky MoMo transfersExercise · 12 min
Classification metrics7 lessons
  • Accuracy and why it liesReading · 4 min
  • Confusion matrixReading · 4 min
  • Precision and recallReading · 4 min
  • F1 scoreReading · 3 min
  • ROC and AUCReading · 4 min
  • Imbalanced data and class_weightReading · 4 min
  • Pick the right threshold for fraudExercise · 15 min
Trees and ensembles7 lessons
  • Decision treesReading · 4 min
  • How a tree splitsReading · 4 min
  • Tree depth and overfittingReading · 4 min
  • Random forestsReading · 4 min
  • Gradient boostingReading · 4 min
  • Feature importanceReading · 4 min
  • Cocoa yield with a forestExercise · 12 min
Tuning models6 lessons
  • HyperparametersReading · 3 min
  • GridSearchCVReading · 4 min
  • RandomizedSearchCVReading · 3 min
  • Learning curvesReading · 4 min
  • Regularisation (Ridge, Lasso)Reading · 4 min
  • Tune the forestExercise · 15 min
Unsupervised learning6 lessons
  • Clustering ideasReading · 3 min
  • k-meansReading · 4 min
  • Choosing kReading · 4 min
  • PCAReading · 4 min
  • Anomaly detection (odd transactions)Reading · 4 min
  • Group Akwaaba customersExercise · 12 min
Responsible ML6 lessons
  • Bias in training dataReading · 4 min
  • Fairness checks by groupReading · 4 min
  • Explaining predictionsReading · 4 min
  • Privacy and Act 843Reading · 4 min
  • A model cardReading · 3 min
  • Fairness check on a loan modelExercise · 15 min
Final project6 lessons
  • Project brief: an end-to-end fraud detectorReading · 4 min
  • Saving a model with joblibReading · 3 min
  • Serving predictions with an APIReading · 3 min
  • Notebooks, Colab and next stepsReading · 3 min
  • Final project: MoMo fraud detectorExercise · 20 min
  • Final quizQuiz · 10 min

Reviews

No reviews yet.

Comments

Log in to join the conversation.

Loading comments...