Algorithms and Programming in Python

ENSAI, second year · Rennes

Course description

The course covers numerical programming in Python and its use to implement optimization and estimation methods for machine learning: least squares, regularized regression with gradient and proximal methods, and Gaussian mixture models. Each session combines a lecture with implementation exercises in Jupyter notebooks.

Prerequisites: basic programming in any language, elementary linear algebra, means and variances, and running commands in a terminal.

Sessions

  1. 1.
    Python, NumPy, and linear regression
    Python and NumPy essentials, array shapes and broadcasting, a reproducible least-squares workflow.
  2. 2.
    Ridge regression
    Gradient descent, momentum and Nesterov acceleration, stochastic gradient descent.
    Materials to be posted.
  3. 3.
    Elastic net
    Proximal gradient descent.
    Materials to be posted.
  4. 4.
    Gaussian mixture models
    Projected gradient descent and the expectation–maximization algorithm.
    Materials to be posted.
  5. 5.
    Reproducibility, metrics, and evaluation
    Materials to be posted.
  6. 6.
    Final exam

Assessment

A three-hour written exam in class, consisting of one exercise closely related to the sessions: adapting an optimization algorithm from the course or applying the course methods to a real-world problem. Online documentation is allowed; LLM assistance is not.

Setup

The materials use Python 3.12 and uv. Installation instructions are in the repository README.