How the training process works

Training a model is an iterative loop of three steps. First the model makes a prediction on a batch
of data. Then the loss function measures how far that prediction is from the true value. Finally the
optimisation algorithm — most often gradient descent — corrects the model parameters to reduce the
error. The loop repeats thousands or millions of times.

Data batch → Prediction → Loss → Gradient → Weight update → ↺

Training ends when the loss stops falling (convergence) or a set number of epochs is reached.

Training types by timing

Offline training (batch training) — the model is trained on a fixed set of historical data. This
is the standard for most recommender systems: training runs on a schedule, weekly for example, and
the new model version replaces the old one.

Online training (incremental or streaming) — the model updates as new data arrives. That allows
it to react to fast shifts in demand: trending products, viral events. It demands more complex
infrastructure.

Important: the less often a model is retrained, the more it goes stale. For e-commerce running
active promotions, recalculating models at least once a week is the recommendation; for
session-based recommendations, keep an online component in place.

Overfitting and regularisation

The main risk in training is overfitting: the model memorises the training sample and loses the
ability to generalise to new data. The symptom is high quality on the training set and low quality
on the holdout or in production.

The countermeasures: L1/L2 regularisation (a penalty on large weights), dropout (randomly switching
neurons off during training) and early stopping (halting when the validation error starts to rise).

Typical mistakes

  • Data leakage — including data from the future in training. The classic example is using
    purchase information that occurred after the event the model is supposed to predict.
  • An unbalanced sample — if 98% of products were never bought together, the model learns to
    predict “will not buy” with high accuracy, which is useless.
  • Retraining too rarely — a model that has never seen the new products cannot recommend them.
    The cold start problem gets worse the longer the retraining cycle.