Machine Learning Foundations with Python

Prepare data, train regression and classification models with scikit-learn, evaluate them honestly and build a tuned pipeline end to end, all in PyCharm.

Beginner · Machine Learning · about 11 hours · 4 modules · certificate on completion

Taught by Khalidà Sultàn, Agnieszka Kowalskà, AI Learning Companions.

About this course

Machine learning is how computers learn patterns from data instead of following rules someone wrote. In this course you learn its foundations by doing them, in Python with scikit-learn and pandas, inside PyCharm. You'll follow the workflow professionals use: explore a dataset, prepare its features (filling gaps, scaling numbers and encoding categories) without leaking test data into training, split off a test set, train models and evaluate them honestly.

You'll predict numbers with linear regression and compare it with a baseline and a random forest, then predict categories with logistic regression, k-nearest neighbours and decision trees, looking beyond accuracy to confusion matrices, precision, recall and decision thresholds. Finally you'll see overfitting happen, use cross-validation to get scores you can trust, and build a pipeline that prepares, tunes, tests and saves a model in one piece. Every dataset comes with scikit-learn, so your results match the ones in the course exactly, and every module ends with a lab you do in PyCharm and submit for your instructor's feedback. The course ends with a handwritten-digit classifier you build end to end.

What you'll learn

  • Follow the machine learning workflow from a question to a tested model
  • Explore data with pandas and prepare it with imputers, scalers and encoders, without leaking test data
  • Train and compare regression models and judge them with MAE, RMSE and R2 against a baseline
  • Train classifiers and judge them with confusion matrices, precision, recall and decision thresholds
  • Detect overfitting, use cross-validation, and tune, test and save a scikit-learn pipeline

Skills you'll gain

Machine learning, scikit-learn, pandas, Data preparation, Regression, Classification, Model evaluation, Cross-validation, Pipelines, PyCharm

Tools

PyCharm, Python 3, pandas, scikit-learn

Before you start

Basic Python: variables, functions, lists and dictionaries, and running a script (the Python Programming with PyCharm course covers them). You need PyCharm (the free version is enough) and Python 3. The course installs pandas and scikit-learn, and every dataset it uses comes with scikit-learn, so nothing else needs downloading.

Modules

  1. The machine learning workflow and your data

    Learn what a model learns from and how a project runs from question to tested model, set up PyCharm for machine learning, then explore and prepare your first dataset.

    • Features, labels and the machine learning workflow (10 min)
    • Exploring a dataset with pandas (12 min)
    • Preparing features: missing values, scaling and encoding (12 min)
    • Hands-on lab: Explore and prepare your first dataset
  2. Regression: predicting numbers

    Fit linear regression to predict a number, measure its errors properly against a baseline, and compare it with more flexible models on the same test set.

    • Linear regression (12 min)
    • Measuring regression error (12 min)
    • Comparing models: regularisation and trees (12 min)
    • Hands-on lab: Predict diabetes progression
  3. Classification: predicting categories

    Train classifiers that predict categories and their probabilities, compare logistic regression, k-nearest neighbours and decision trees, and judge them with confusion matrices, precision and recall.

    • Logistic regression and probabilities (12 min)
    • k-nearest neighbours and decision trees (12 min)
    • Confusion matrices, precision and recall (12 min)
    • Hands-on lab: Catch malignant tumours
  4. Evaluating models and building a pipeline

    See overfitting happen, get scores you can trust with cross-validation, and build a pipeline that prepares, tunes, tests and saves a model end to end.

    • Overfitting and underfitting (12 min)
    • Cross-validation (12 min)
    • A pipeline end to end: tune, test and save (14 min)
    • Hands-on lab: Find overfitting, then tune and save a pipeline

Project: Build a handwritten digit classifier end to end

scikit-learn's load_digits dataset holds 1,797 small images of handwritten digits, each 8 by 8 pixels, stored as 64 numbers from 0 to 16, with the digit 0 to 9 as its label. Build a classifier for it in PyCharm, following the whole workflow: explore the data (including showing a few images with matplotlib or as printed grids), split off a stratified test set, set a baseline, compare at least three models with cross-validation, tune the best with GridSearchCV inside a pipeline, test it once, and study its mistakes with a confusion matrix: which digits does it confuse, and why might that be? Save the final pipeline with joblib and write a small predict.py that loads it and predicts the label of a few test images.

Part of

PyCharm is a trademark of JetBrains s.r.o. This course is independent: JetBrains hasn't made or endorsed it.

Start the course free