Python for Machine Learning

Python for Machine Learning icon

Python for Machine Learning

About This Course

Machine learning is the part of your analysis that makes a prediction and then has to be trusted with it. This course covers the supervised and unsupervised methods that do most of the work on tabular data, using scikit-learn, and spends as much time on checking a model as on fitting one.

Day 1 builds the foundations. You fit regression models and look at what they get wrong, since residuals tell you more about a fit than a single score does, and work through the transformations and robust methods that handle data which is not a straight line. The day also covers the unsupervised techniques that often come first in practice, when the data arrives without labels: clustering with K-means and DBSCAN, and detecting the outliers and anomalies that turn up in fraud detection and quality assurance.

Day 2 is supervised learning end to end. You fit classifiers, then spend real time on the parts that decide whether a model is trustworthy: cross-validation, the curves that show whether more data or a different model would help, and tuning that does not quietly consume the test set. Feature engineering gets the attention it deserves, because it is the part that cannot be automated away, and we build the preprocessing into pipelines so the transformations applied during training are the ones applied at prediction time. The day ends outside the notebook, persisting a model, serving it behind an API, and watching for the dataset shift that degrades it after release.

The course works on real datasets throughout, so the awkward parts show up: mixed numeric and categorical columns, missing values, and classes that are rare enough to break a naive split. Deep learning is not covered here — this is scikit-learn on tabular data, which is what most production models still are.

Who This Course Is For

Data scientists, analysts, quants, researchers, statisticians and software developers who already write Python and now need to predict something from their own data rather than describe it. It suits people who can produce a summary table or a chart, and who are asked what next month's figure will be, which customers to look at first, or which readings are wrong.

It also suits teams where models are built occasionally and by one person at a time, so results are hard to compare and harder to defend. Everyone leaves using the same scikit-learn interface and the same validation vocabulary.

Prerequisites

This course is designed to be able to be completed immediately after completing Python Charmers' Introduction to Python course, or equivalent programming experience (approximately 3 months of regular usage).

You should be comfortable loading and filtering tabular data in Polars or Pandas, since every model we build is fitted from a DataFrame or a NumPy array. No prior machine learning experience is assumed. High-school mathematics is enough; some probability and statistics helps but is not required, and you will not be asked to derive anything.

What You'll Learn

  • Fit and interpret regression models, and read the residuals to see where a fit is failing.
  • Build classifiers with scikit-learn, choosing between nearest neighbours, random forests and support vector machines for the problem at hand.
  • Find structure and unusual points in unlabelled data using clustering and outlier detection.
  • Validate a model with cross-validation, score it with metrics that suit the problem, and diagnose overfitting from validation and learning curves.
  • Assemble preprocessing and estimation into a scikit-learn pipeline that keeps held-out data genuinely held out.
  • Put a trained model behind an API and monitor it for degradation once it is in use.

Course Syllabus

Day 1: Modelling foundations

  • Machine learning concepts and the scikit-learn estimator interface
  • The Python machine learning package ecosystem, and what to reach for when
  • Regression: simple, multiple, nonlinear and robust
  • Measuring regression quality, and reading residuals
  • Clustering with K-means and DBSCAN
  • Outlier and anomaly detection, including ensembles with pyOD

Day 2: Supervised learning end to end

  • Classification with scikit-learn, and reading a confusion matrix
  • Choosing an algorithm: nearest neighbours, random forests, support vector machines
  • Validation and model selection: cross-validation, validation and learning curves
  • Hyperparameter tuning with GridSearchCV and RandomizedSearchCV
  • Feature engineering and selection: encoding, scaling, permutation importance
  • Building preprocessing pipelines with Pipeline and ColumnTransformer, and avoiding leakage
  • Persisting a model and serving it behind an API, and monitoring it for drift in production

Worked applications are drawn from real datasets rather than toy examples.

Upcoming Sessions

Questions?

Need help choosing the right course or have questions about content?

Contact Us