Hyperparameter
Definition
A hyperparameter is a setting in a machine learning algorithm that is not learned from the data during training, but instead set before training begins.
- They control how the model learns or how it is structured.
- Contrast with parameters (weights, biases) → learned automatically by the model.
Examples of Hyperparameters
- Model Structure
- Number of layers in a neural network.
- Number of neurons per layer.
- Maximum depth of a decision tree.
- Training Process
- Learning rate (step size for weight updates).
- Batch size.
- Number of epochs.
- Dropout rate (in NN).
- Regularization
- L1/L2 penalty strength (Ridge, Lasso).
- Weight decay.
- Optimization Algorithms
- Momentum parameter (for SGD).
- Beta values in Adam optimizer.
Why Hyperparameters Matter
- Different hyperparameter choices can lead to very different performance.
- Bad choices → underfitting, overfitting, slow training.
- Good tuning = critical for maximizing accuracy and generalization.
Hyperparameters vs Parameters
| Parameters (learned) | Hyperparameters (set manually/externally) |
|---|---|
| Learned during training (via optimization) | Defined before training |
| Example: weights, biases | Example: learning rate, # of layers |
| Represent model’s “knowledge” | Represent model’s “learning strategy” |
Tuning Hyperparameters
- Manual tuning → try different values based on intuition.
- Grid search → test across a full set of combinations.
- Random search → randomly sample combinations (often more efficient).
- Bayesian optimization → use probability models to search smartly.
- Hyperband / Population-based tuning → efficient large-scale methods.
Example
- Train a neural net on MNIST digits.
- Hyperparameters:
- Learning rate = 0.001
- Batch size = 64
- Dropout rate = 0.5
- Epochs = 20
- Model learns parameters (weights) automatically, but performance depends heavily on chosen hyperparameters.
Summary
Hyperparameters = configuration choices set before training that control how a model learns or is structured.
- Examples: learning rate, tree depth, dropout rate.
- Must be tuned carefully (grid search, random search, Bayesian).
Discover more from Insightful Data Lab
Subscribe to get the latest posts sent to your email.
