Skip to main content
Hyperparameter tuning (also called hyperparameter optimization, HPO) is the process of selecting the best set of hyperparameters for a machine learning model. Hyperparameters are set before training — unlike model parameters (weights, biases) that are learned — and they control data preprocessing, training dynamics, model capacity, and evaluation. Choosing the right hyperparameters is essential for building models that generalize well and are stable in production. Why tuning matters
  • Correct hyperparameters control the trade-off between underfitting and overfitting.
  • They influence convergence speed, final accuracy, and resource usage (compute and time).
  • Effective tuning can reduce cost by lowering the number of expensive training runs needed to reach target performance.
The image illustrates the process of why tuning matters in machine learning, showing a flow from input data to a model, resulting in high-quality predictions, with hyperparameter tuning as a key component.
Types of hyperparameters Hyperparameters fall into several categories depending on what aspect of the training or model they affect:
  • Model-specific: number of layers, number of neurons, max depth (decision trees), kernel type (SVM).
  • Regularization: L1/L2 penalties, dropout rate, weight decay.
  • Training process: learning rate, batch size, optimizer, number of epochs.
  • Evaluation / early stopping: validation split, early-stopping patience, checkpoint frequency.
Table: common hyperparameter categories and examples
The image is a slide titled "Common Hyperparameters," highlighting model-specific parameters such as layers/neurons, max depth, and kernel type, with a geometric icon on the left.
Overview of tuning strategies Common tuning strategies include manual tuning, grid search, random search, and Bayesian optimization. Each technique balances exploration, exploitation, cost, and the number of training trials differently. Choose the method that fits your compute budget, search space size, and required repeatability.
The image outlines tuning techniques with three options: Manual Tuning, Grid Search, and Random Search. It includes a process flow of "Try," "Train," "Evaluate," and "Adjust," indicating a repeatable cycle.
Comparative summary of tuning techniques Manual tuning
  • Pros: Simple, increases practitioner intuition about which hyperparameters matter.
  • Cons: Time-consuming, not scalable, often yields suboptimal configurations.
  • When to use: Exploratory experiments, small models, or educational settings.
Grid search Grid search evaluates all combinations from a pre-specified grid of values.
  • Pros: Exhaustive within the grid and easy to parallelize.
  • Cons: Infeasible for large or continuous search spaces; wastes trials on unimportant parameters.
  • When to use: Low-dimensional, discrete search spaces where guaranteed grid coverage is desired.
The image presents tuning techniques with a focus on "Grid Search", highlighting its pros (exhaustive, easy to parallelize) and cons (slow for large spaces, wasteful with irrelevant combinations).
Random search Random search samples configurations from specified distributions or discrete sets.
  • Pros: More efficient than grid search in many practical high-dimensional problems; tends to find good configurations with fewer trials.
  • Cons: Still random and can miss narrow optimal regions.
  • When to use: Medium-to-large search spaces where budget is limited and you want broader coverage than a grid.
The image shows a diagram of tuning techniques for machine learning, highlighting Manual Tuning, Grid Search, and Random Search with parameters for learning rate and batch size.
The image presents tuning techniques, highlighting "Random Search" with pros like efficiency and speed, and cons like potentially missing optimal values.
Bayesian optimization Bayesian optimization constructs a probabilistic surrogate (often a Gaussian Process) to model the relationship between hyperparameters and the objective metric. An acquisition function (e.g., Expected Improvement, Upper Confidence Bound) selects the most promising hyperparameters to evaluate next, yielding sample-efficient search that typically converges faster than grid or random search.
  • Pros: Great for expensive-to-evaluate objectives; reduces number of required trials.
  • Cons: Additional implementation complexity; surrogate model overhead for many parallel experiments.
  • When to use: Long training runs, costly compute (GPU/TPU), or when each trial is expensive in time or money.
The image depicts a graph illustrating Bayesian Optimization with GP (Gaussian Process) estimation, showing the true function, GP mean, confidence interval, and observed values. It emphasizes smarter, fewer trials and faster convergence in tuning techniques.
Amazon SageMaker hyperparameter tuning Amazon SageMaker exposes managed hyperparameter tuning jobs (HPO) to orchestrate many training jobs with different hyperparameter combinations. SageMaker handles parallelization, resource provisioning, logging, and supports both random and Bayesian (SMBO) optimization strategies, making it practical for production pipelines where scale, cost control, and observability are important.
  • Key features:
    • Define hyperparameter ranges and distributions.
    • Choose optimization strategies (random or Bayesian/SMBO).
    • Run many training jobs in parallel with resource management.
    • Aggregate results, log metrics, and automatically select the best model.
The image illustrates the Amazon SageMaker automatic model tuning process, showing the flow from data preprocessing to tuning jobs and model deployment, integrated with various AWS services like ECR, EBS, and CloudWatch.
When to prefer managed or Bayesian HPO
  • Use Bayesian optimization or a managed HPO service (like SageMaker HPO) when training is expensive or each trial takes hours/days.
  • Use random search for a balance of simplicity and efficiency on larger search spaces.
  • Reserve grid search for small, discrete, and well-bounded parameter grids.
When training is expensive (long training times or high compute cost), prefer Bayesian optimization or managed tuning services that reduce the number of trials needed to find a good configuration.
Further reading and references Use these techniques and tools to match your problem constraints — computation budget, time-to-result, and repeatability — and to move from intuition-driven experiments to production-ready, well-tuned models.

Watch Video