MODULE 10 ยท Junior+ ยท 90 minutes

A gain of 0.005 against a spread of 0.004 is noise

One day and one server shared by three teams. We tune deliberately and learn to tell a real improvement from a random swing of cross-validation.

Open this module in the simulator All 23 lessons

The first two modules are free, no card. The rest are $20/month.

๐Ÿข The situation

Friday. Lena:

"The LightGBM churn model is good, but you trained it on default parameters. Before rolling out to the whole base, let's squeeze out the maximum. Just no fanaticism: you have one day and one GPU server shared by three teams. Show that you can tune efficiently โ€” not by brute force, but with brains. And don't tune the model into 'perfect on validation, useless in production'."

๐ŸŽฏ Your task

  1. Understand which hyperparameters matter and why.
  2. Compare grid search, random search and Bayesian optimization (Optuna).
  3. Avoid overfitting to the validation set.

๐Ÿ“š Theory

Parameters vs hyperparameters

Three search strategies

Strategy How it works When
Grid search full sweep of a grid 2โ€“3 parameters with few values
Random search random points from distributions the default choice: for the same budget it covers the space better (Bergstra & Bengio, 2012)
Bayesian (Optuna, TPE) builds a "parameters โ†’ quality" model and tries promising points expensive training, many parameters โ€” the industry standard

Why random > grid: if only 1 of 3 parameters matters, a 5ร—5ร—5 grid tries just 5 unique values of the important one; random tries all 125.

Grid search: 25 trials along the important X axis โ€” only 5 distinct values Random search: 25 trials along the important X axis โ€” 25 distinct values
The same trial budget: the grid wastes it on repeats along each axis, random search covers every axis fully (Bergstra & Bengio, 2012).

What to tune in gradient boosting (in order of importance)

  1. learning_rate + n_estimators (with early stopping โ€” fix a lowish LR, plenty of trees);
  2. num_leaves / max_depth โ€” model capacity;
  3. min_child_samples โ€” leaf regularization;
  4. feature_fraction, bagging_fraction โ€” stochasticity;
  5. lambda_l1, lambda_l2 โ€” if it still overfits.

Overfitting to validation โ€” the silent killer

Hundreds of tuning iterations against a single validation set = you "fit" the model to it. Rules:


What to remember

  • Random search beats grid search almost always; Optuna is the standard for expensive training.
  • Tune with CV, measure once on an untouched test.
  • A gain smaller than the CV std is noise.
  • Tuning is the last optimization step, not the first.

Next in this module: Practice: Optuna

Open the module โ†’

Nearby lessons

09 Incident: the model fell apart in production 11 Fraud: 1 fraudster per 1000 honest users

The whole program โ€” 23 lessons