Hyperparameter
A setting chosen before training (like k, tree depth or learning rate), not learned from the data.
Parameters are learned during training (the weights of a regression, the splits of a tree). Hyperparameters control how learning happens: the number of neighbours in k-NN, the depth of a tree, in ridge, the learning rate and batch size of a network.
They are tuned on validation data, by grid search, random search or Bayesian optimisation, combined with cross-validation. Tuning on the test set makes the final score optimistic.
See it in action
- k-nearest neighboursPredict from the most similar training examples: no training, one knob, and a lesson about distance.
- Decision treesLearn a flowchart of yes/no questions: greedy splits, impurity, depth and pruning.
- Ridge, lasso and elastic netRegularised regression: shrink weights to fight overfitting, and let lasso select features.
- Bias, variance and cross-validationWhy models fail to generalise, the error decomposition, and how cross-validation chooses complexity.