liveBook · Manning

Hyperparameter tuning

As explained in Machine Learning System Design

Hyperparameter optimization is the process of searching for configuration values that improve a model's performance.

Hyperparameter tuning searches for configuration values that improve model performance. Treat it as part of the training pipeline: first identify likely low-hanging experiments, then choose a search strategy that matches dataset size, experiment duration, and available compute. section 10.4

A practical tuning workflow includes these decisions:

  • Select parameters that are genuinely changeable for the pipeline; do not make every model function configurable by default. section 10.4
  • Use handcrafted experiments when compute is limited or individual runs take weeks; use random search or Bayesian optimization when resources support many runs. section 10.4
  • Record parameters, input data, feature engineering, metrics, and model artifacts so experiments can be compared and managed. section 10.6.1
  • Protect the test set: repeatedly searching against one validation split can overfit it and produce biased, nonrobust results. section 7.1

Forecasting at Supermegaretail

A retail forecasting pipeline can tune configurations across baseline, classical ML, and deep learning models using grid search or Bayesian optimization. It should judge candidates with MAE, MSE, RMSE, quantile metrics, confidence intervals, and business costs for overstock and out-of-stock situations. section 10.6.1

Listing 10.1 Multilevel hierarchy of subcodings
def train():
   ...
   batch_size = 32
   ... 
   learning_rate = 3e-4
   ...
   model.train(data, batch_size, loss_fn)
   ...   

^ example of underconfigured code: things are too rigid  


class Config(BaseConfig):
    def __init__(self):
        self.data_config = DataConfig()
        self.model_config = ModelConfig()
        self.training_config = TrainingConfig()
        self.inference_config = InferenceConfig()
        self.environment_config = EnvironmentConfig()


class DataConfig(BaseConfig):
    def __init__(self):
        self.train_data_config = TrainDataConfig()
        self.validation_data_config = ValidationDataConfig()
        self.test_data_config = TestDataConfig()


config = Config(
    data_config=DataConfig(
        train_data_config=TrainDataConfig(
            ...
        ),
        validation_data_config=ValidationDataConfig(
            ...
        ),
        test_data_config=TestDataConfig(
            ...
        ),
    ),
    ...
)

A hierarchical configuration example shows how data, model, training, inference, and environment settings can be separated instead of hard-coding values inside the training function. section 10.4

How Machine Learning System Design covers it

How deep it goes
Explains parameter selection, manual and automated search, experiment tracking, and validation risks without deriving search algorithms.
Examples
Uses retail forecasting, grid search, Bayesian optimization, random search, MLflow tracking, and hierarchical configuration files.
What it assumes
Assumes training, validation, and test splits, while emphasizing that validation must be repeated as system context changes.
What you can do after
Apply it via random search, Bayesian optimization, grid search, or controlled manual experiments while tracking results and protecting evaluation data.
How it connects
Connects hyperparameter tuning to training pipelines, model selection, validation, experiment tracking, Bayesian optimization, and grid search.

Also explained in

Compare how 18 books explain hyperparameter tuning →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Machine Learning System Design. The section links point to the parts of the book it draws on.