Foundations

Machine Learning (ML)

Machine learning is the practice of writing programs that learn a function from data, via a loss function and an optimizer, instead of following hand-written rules.

Machine learning (ML) is the practice of building systems that learn a function from examples, rather than following hand-written rules. The core recipe: a model (a function with adjustable parameters), a loss function (a number measuring how wrong its predictions are), and an optimizer (usually gradient descent) that adjusts the parameters to reduce that loss. Deep learning is the subfield of ML built on neural networks.

How it works

The standard workflow is the same whether the model is a linear regression or a transformer:

  1. Split the data into train, validation, and test sets — see train/validation/test split.
  2. Choose a model family and initialize its parameters.
  3. Loop: predict on a batch, score with the loss, compute gradients, update the parameters.
  4. Check validation error to pick hyperparameters and decide when to stop.
  5. Report on the test set once.

The main learning settings differ in what signal is available. Supervised learning has input–label pairs; unsupervised learning has inputs only and looks for structure; self-supervised learning manufactures labels from the input itself (predict the next token); reinforcement learning receives a reward after acting.

When it breaks

  • Data leakage. Any signal that reaches training but will not exist at prediction time — a target-derived feature, duplicated rows across splits, normalizing before splitting — produces validation scores that evaporate in production.
  • Non-random splits. Time series must be split chronologically; grouped data (multiple rows per user) must be split by group, or the model memorizes the group.
  • Optimizing the wrong objective. The loss you can differentiate is rarely the outcome the business cares about.
  • Stale models. Input distributions drift, and a model that is never retrained degrades quietly with no error signal.

See also: Loss Function, Gradient Descent, Overfitting

Learn more: ML Fundamentals · Wikipedia: Machine learning

Mentioned in

Lessons where this comes up in context.

On this page