Module 4 · step 4 of 5 · Training and comparing runs

Improve a model

Tune the best algorithm and check whether the new candidate beats where you started.

App8 min

In this step you will tune the best candidate of your run and check the result against where you started. It matters because tuning costs compute and can overfit the search, so you want numbers that tell you whether it paid off.

The idea

A first run tells you which algorithms suit your data. Improving means spending more compute on the best ones. Tuning searches better hyperparameters (the settings of one algorithm, such as tree depth) and scores each try with cross-validation. Every action trains a new candidate inside the same run and never replaces the old ones, so you can always compare against the start.

The risk is overfitting the search: the more combinations you try, the likelier one looks good by chance. The Tuning history chart shows the CV score of each trial and Best so far; if the best score appeared in the last few trials, a longer search might still help.

Step by step

  1. Open your finished run and select View details on the best candidate.
  2. In the page header open Improve and select Tune. In the dialog set Search iterations (the default is 10) and leave Optimize metric on the engine default, or pick Recall if missing a churner is costly. Select Start tuning.
  3. Watch the stage in the event log (Tuning hyperparameters, then Tuning complete). A new candidate labelled tuned appears in the run.
  4. Open it and read Tuning history, Best hyperparameters and Tuned from, which points to the original.
  5. Go to the Leaderboard tab, tick the tuned candidate and the original, and select Compare. Read the Winner column and the difference.
  6. Decide. Keep the tuned model only if it beats the original by more than a tie and its Training time and Model size are acceptable.

Tuning is a training job. In the demo, keep an eye on the allowance of 10 runs and wait for each job to finish before starting the next. Blending and stacking come in the next step.

Common mistakes

  • Tuning before choosing the algorithm. Compare many algorithms with defaults first, then tune the top one or two.
  • Believing a small improvement. If the score barely moves, Compare says tie.
  • Expecting the original to change. It stays in the run; the tuned model is a new row.
  • Starting another job while one is running. The event log shows the current stage; wait for it to end.

As a data scientist

Tuning is the last gain, not the first: better data and preprocessing usually move the score more than a wider search. Keep the search budget modest, trust only cross-validated scores and keep the original as your reference. mlflow keeps both, so the comparison costs nothing.

Checkpoint

You should see a new candidate labelled tuned in the leaderboard, next to the original, with a Tuning history and the Best hyperparameters on its page.

Theory to read next

Read in the docs