Skip to Main Content

Risk & Quant

Overfitting

Overfitting is the tailoring of a model or trading strategy to sample-specific variation, so it fits its historical data well but performs worse on new observations.
Also Called
  • Curve Fitting
  • Data Snooping
  • Over-Optimization
By InsiderFinance TeamUpdated Sources & Methodology

Compare Development and Evaluation Performance

Compare Development and Evaluation PerformanceLine chart of 49 points with 2 overlays (hline), 3 trade markers.100200300400123012243648
Compare Development and Evaluation PerformanceLine chart of 49 points with 2 overlays (hline), 3 trade markers.100200300400123012243648

Account Index (start = 100) over Months

Months: 1: 0, 2: 1, 3: 2, 4: 3, 5: 4, 6: 5, 7: 6, 8: 7, 9: 8, 10: 9, 11: 10, 12: 11, 13: 12, 14: 13, 15: 14, 16: 15, 17: 16, 18: 17, 19: 18, 20: 19, 21: 20, 22: 21, 23: 22, 24: 23, 25: 24, 26: 25, 27: 26, 28: 27, 29: 28, 30: 29, 31: 30, 32: 31, 33: 32, 34: 33, 35: 34, 36: 35, 37: 36, 38: 37, 39: 38, 40: 39, 41: 40, 42: 41, 43: 42, 44: 43, 45: 44, 46: 45, 47: 46, 48: 47, 49: 48

Modeled Account IndexPre-Drawdown Peak 349Trough 272
  1. 1Out-of-Sample Begins at 340
  2. 2Peak 349
  3. 322.1% Drawdown
Development: 100 to 340 over 36 months, or 50.4% CAGR. Evaluation: 340 to 352 over 12 months, or 3.5%, with a 22.1% peak-to-trough drawdown.
On This Page
  1. What is overfitting?
  2. Overfitting example: a 400-combination search
  3. Overfitting and the bias-variance decomposition
  4. Data snooping and the size of the strategy search
  5. How to detect and avoid overfitting
  6. Limitations of overfitting checks
  7. Bottom line
  8. FAQ

Key Takeaways

  • Overfitting is the tendency to tailor a model or strategy to the training data at the expense of generalizing to new data.
  • An overfit strategy captures random noise that will not repeat, so a strong backtest can degrade badly out of sample.
  • Evaluate the full selection process, including candidate rules, parameter grids, features and any validation results used to choose them.
  • Use chronological validation, regularization and a reserved final evaluation to assess how the selected procedure generalizes.
  • Compare performance across samples and parameter settings, and investigate changes in data, exposure and execution alongside model selection.

What is overfitting?

Overfitting is the tailoring of a model or trading strategy to sample-specific variation at the expense of its performance on new observations. It can arise from a flexible estimator, repeated rule changes or selection across many candidate strategies. An overfit strategy can post a strong backtest because it has fit noise in that history, and its results can degrade sharply on new data.

Curve fitting is a general estimation activity. The evaluation question is whether the fitted procedure transfers to the observations it was designed to predict or trade.

Formula

For squared-error prediction at x: expected test error = squared bias + prediction variance + irreducible noise variance.
  • Bias is the difference between the average fitted prediction across training samples and the conditional mean outcome. The decomposition uses its square.
  • Prediction variance measures how fitted predictions vary across training samples. The identity covers squared-error prediction; judge a Sharpe ratio or trading profit on reserved data.
  • Noise variance is the conditional variance of the outcome at x, with test noise independent of the training sample in this decomposition.

A trader selects a moving-average length and stop distance from 400 combinations using 36 months, then evaluates the selected procedure for 12 months. The chart shows the resulting constructed monthly account path from a starting index value of 100.

  • Development window: 36 monthly returns, from index value 100 to 340; CAGR = (340 / 100)^(1/3) − 1 = 50.4%.
  • Search: two selected parameters across 400 candidate combinations.
  • Evaluation window: 12 monthly returns, from 340 to 352; total return = 3.5%.
  • Evaluation-window peak 349 and trough 272 give maximum drawdown 22.1%.

The winning configuration’s development CAGR is 50.4%, while the next year returns 3.5% with a 22.1% maximum drawdown. Weigh that gap against the candidate search, market conditions and execution record to judge how the winner transfers.

The constructed chart contains 49 monthly account values. Its first 36 returns move the account index from 100 to 340, giving a three-year CAGR of 50.4%.

The next 12 returns move it from 340 to 352, giving 3.5%. Within that year, a 349 peak followed by a 272 trough produces a 22.1% maximum drawdown.

The example selects two parameters from 400 candidate combinations before that evaluation period. Analyze that gap starting with the 400-way search, then check costs, exposure and data for their share.

Overfitting and the bias-variance decomposition

For a prediction at a fixed input x, expected squared test error can be separated into squared bias, prediction variance and conditional noise variance under the specified training and test setup.

Bias compares the average fitted prediction with the conditional mean outcome. Prediction variance measures variation across training samples. Noise variance belongs to the outcome given x.

The identity covers squared-error prediction; measure a Sharpe ratio or trading profit directly on reserved data.

The candidate set includes indicators, filters, parameters, universe definitions and validation designs. Adding candidates cannot lower the best score on the same selection dataset, but that maximum alone does not measure generalization.

Keep the search procedure and its evaluation distinct. A simple final rule can still be the winner of a large search; a regularized flexible model can have controlled effective complexity.

How to detect and avoid overfitting

Fit preprocessing, features and parameters within each permitted training window. Evaluate the next period using the predefined update and execution rules. Define the entry, exit, position size and contract handling before evaluating the resulting strategy on its reserved record.

If validation results guide another choice, use that data as validation for the revised procedure and retain a separate final evaluation. In time-series work, preserve chronology and the availability of training outcomes.

Review parameter sensitivity, market exposure, transaction costs and data changes together. These comparisons identify where performance differs and what to investigate next.

Limitations of overfitting checks

  • Run every check together. Reserved data, nearby parameter settings and the size of the search each test a different weakness, and a strong result on one reserved period still carries that period’s market conditions.
  • Split the gap before blaming the search. Changes in market exposure, data or execution also open a gap like the drop from 50.4% to 3.5%.
  • Use each reserved period as a clean test once. After its results guide another choice, it becomes validation data for the revised procedure, so keep a separate final period for the revision.
  • Count the whole search, including the rules you discarded: a simple final rule that won 400 tries carries the bias of the whole search. Judge Sharpe ratio and trading profit on reserved data, since the bias-variance identity covers squared-error prediction.

Bottom line

Overfitting turns noise in historical data into a strategy that looks better in testing than it performs on new data. Count every candidate tested, reserve data before the search begins, and judge the frozen procedure on that reserved record together with parameter sensitivity, costs and market exposure.

Clear answers

Frequently Asked Questions

Sources and Further Reading

  1. CFA Institute: Machine Learning (refresher reading)
  2. CFA Institute: Backtesting and Simulation (refresher reading)
  3. CFA Institute: How Machine Learning Is Transforming the Investment Process

How entries are sourced, calculated and updated: editorial methodology.

Continue learning