Hyperparameters vs Parameters
Parameters are the numbers a model learns from data during training; hyperparameters are the numbers a human sets before training even starts, and confusing the two is one of the fastest ways to leak the future into a backtest.
Prerequisites: Gradient Descent
A trading desk has two kinds of numbers on its books. There are position sizes and hedge ratios recalculated every day from fresh data — those adjust automatically as conditions change. And there are the rules of the desk itself — max leverage, the stop-loss threshold, how many days of history the risk model looks back over — decided in advance, which daily recalculation never touches. Get those rules wrong and no amount of correct daily recalculation saves you. A machine learning model has exactly this split, and the two kinds of numbers have different names.
Parameters are the numbers a model fits from the training data. In linear regression these are the coefficients ; in a neural network they are every weight and bias; in a decision tree they are the specific split points chosen at each node. Nobody sets these directly — an optimization procedure like gradient descent searches for the values that minimize the training loss, and the model literally cannot be trained without discovering them.
Hyperparameters are the numbers a human (or an automated search) fixes before training begins and that training itself never touches. The learning rate in gradient descent, the number of trees in a random forest, the maximum depth of a single tree, the regularization strength , the number of layers in a network — all of these are chosen ahead of time and stay fixed while the parameters are being learned. Change a hyperparameter and you are effectively training a different model from scratch, not continuing the same one.
The mechanical test: does the loss function's gradient touch it?
The cleanest way to tell them apart: parameters appear inside the loss function being differentiated during training — gradient descent adjusts them directly because the loss is a function of them. Hyperparameters shape the loss function or the optimization procedure itself but never appear as a variable being solved for.
In words: training finds the parameter values that minimize a loss (how badly the model fits the data) plus a penalty term scaled by . The search happens over — that's what "" means, find the that minimizes this. But itself is never searched over by this equation; it sits outside the minimization, fixed as a constant chosen beforehand. is a parameter. is a hyperparameter.
Drag the learning rate here and watch the descent path change completely — crawling, converging cleanly, or overshooting into oscillation. The learning rate is a textbook hyperparameter: it controls how the parameters get found, but it is never itself among the numbers being solved for by the descent.
Worked example 1: ridge regression, counted out
Fit ridge regression, , with penalty strength , on a small dataset. Training runs and returns , , . Those three numbers are parameters — they came out of the optimization, different data would produce different values, and re-running training on the same data with the same reproduces them. is a hyperparameter — it was chosen before fitting (perhaps by cross-validation over a grid like ), and the fitting procedure never adjusts it; if you want a different , you rerun training entirely, you don't "continue" the old fit.
Worked example 2: counting a small neural network
A network has one hidden layer of 8 units, ReLU activation, trained with Adam at learning rate for 50 epochs, dropout . Count the parameters: with 5 input features, the hidden layer has weights plus 8 biases ; the output layer has weights plus 1 bias . Total: parameters, every one a number training searches over. Now count the hyperparameters fixed beforehand: layer count, units per layer, activation choice, optimizer, learning rate, epoch count, dropout rate — seven human decisions, none of which the 57-parameter optimization ever revisits.
Parameters are found by training; hyperparameters are decided before training and define what "training" even means for this run — if you find yourself tuning a number by watching the training loss go down, you are almost certainly (and incorrectly) treating a hyperparameter like a parameter.
What this means in practice
Hyperparameters have to be chosen using data the model's final performance will be judged on being kept separate from — typically a validation set distinct from both the training set (where parameters are fit) and the test set (where the finished model is judged once, at the end). Skipping this and picking the learning rate, tree depth, or lookback window by watching how well it does on the same data used for both fitting and final evaluation quietly turns the hyperparameter search into another form of overfitting, just one layer up from the parameters themselves.
The classic trap in quant research is tuning a hyperparameter — say, a moving-average lookback window, a lag length, or a regularization strength — directly against the full backtest's Sharpe ratio, then reporting that same backtest's Sharpe ratio as the strategy's expected performance. The lookback window is a hyperparameter chosen using the test data itself, which means the backtest is no longer an honest out-of-sample evaluation; it has been implicitly fit to the very period it's supposed to be testing. This is a form of look-ahead bias that survives even a strict train/test split on the parameters, because the split was never applied to the hyperparameter choice.
Related concepts
Practice in interviews
Further reading
- Hastie, Tibshirani & Friedman, The Elements of Statistical Learning, ch. 7
- Goodfellow, Bengio & Courville, Deep Learning, ch. 11