Forecasting returns: overfitting, cross-validation and why it's hard
Flexible models can fit any history, and in noisy financial data that mostly means fitting noise. How overfitting inflates in-sample results and wrecks out-of-sample ones, why time-series data needs walk-forward rather than random cross-validation, the leakage traps that ruin backtests, and what realistic success looks like.
Facts reviewed Oct 2026
Give a powerful machine learning model enough variables and it can explain almost all of the past movements in a stock index. That’s the problem. Financial returns are mostly noise, so a model flexible enough to fit history closely is mostly fitting noise, which won’t repeat. This lesson explains overfitting, the right way to test forecasting models, and why modest results are the honest ones.
Overfitting
Overfitting means a model learns the random quirks of its training data rather than the underlying pattern. Symptoms:
- excellent performance in sample (on the data used to build it),
- poor or negative performance out of sample (on new data).
The risk grows with the number of features and parameters relative to the amount of data, and with how weak the true signal is. In return forecasting, the true signal is very weak and the data is short, the worst combination.
How noise inflates fit
For a linear model with k predictors fitted to n observations, pure noise alone adds roughly k ÷ n to the in-sample R², and out of sample the model does roughly that much worse than its true predictive power.
Suppose the truly predictable share of monthly returns is 1% (an R² of 1%, which would be valuable), and a model uses 20 features on 240 months (20 years). In sample, it shows an R² of about 9%, which looks impressive. Out of sample, it’s expected to be about −7%: worse than simply predicting the average. With this much data, the model can afford only about 2 features before overfitting outweighs the signal.
A rough approximation for linear models with independent, noisy data; flexible ML models can overfit even more. Defaults: about 9.25% in sample against about −7.25% out of sample, with only 2 features affordable. More data or fewer features narrow the gap.
A return-forecasting model has an in-sample R² of 35% using 50 features on 10 years of monthly data. What's the most likely explanation?
With 50 features and only 120 observations, much of the fit is noise. Genuine monthly return predictability is small, a few percent at most.
Cross-validation done right
Cross-validation estimates out-of-sample performance by repeatedly training on part of the data and testing on the rest. In most ML applications, the data is split randomly. For financial time series, that’s a mistake: random splits let the model train on the future and test on the past, and overlapping returns leak information across folds.
Use walk-forward (rolling-origin) validation instead:
- Train on data up to a point in time.
- Test on the next period only.
- Move forward and repeat.
Add a gap between training and test periods when labels overlap, such as 12-month returns measured monthly, so information doesn’t leak.
Leakage: the silent killer
Data leakage means the model sees information it wouldn’t have had at the time:
- using revised economic data or restated financials instead of what was known then,
- survivorship bias: training only on companies that still exist, as Spreadsheets & Python for Finance’s data lesson describes,
- normalising features with statistics from the whole sample, including the future,
- look-ahead in labels or features, such as using the closing price to trade at the close.
Leakage makes backtests look brilliant and live trading disappointing.
Regularisation and simplicity
Defences against overfitting include:
- Regularisation (ridge, lasso, limits on tree depth) that penalises complexity,
- fewer, economically motivated features, rather than hundreds of mined ones,
- ensembles that average many models,
- a final hold-out period that is used only once, at the end,
- multiple-testing adjustments, as Statistics & Probability for Finance’s last lesson explains.
What success looks like
Academic research has found that machine learning can improve return forecasts a little over simple models, especially by capturing non-linear interactions between known factors. But realistic out-of-sample R² for monthly stock returns is around 1% or less, and gains shrink after costs and as others find the same patterns. Anyone claiming much more should be asked how they tested it.
Try it: with 20 years of daily data (about 5,000 observations) and a true R² of 0.5%, how many features can a model afford?
About 25 features before overfitting outweighs the signal: 5,000 × 0.005 ÷ 0.995 ≈ 25. Enter 0.5, 20 and 5000. More data helps, but daily returns are even noisier, so the true R² is usually tiny.
Key takeaways
- Overfitting fits noise: great in sample, poor out of sample; worst with weak signals, many features and little data, exactly the return-forecasting setting.
- Noise adds roughly k ÷ n to in-sample R² and subtracts it out of sample.
- Use walk-forward validation with gaps, not random splits; avoid leakage from revised data, survivorship, full-sample scaling and look-ahead.
- Defend with regularisation, fewer features, ensembles and a final hold-out; realistic monthly R² is around 1%.
Go deeper
- Gu, Kelly and Xiu: Empirical asset pricing via machine learning (NBER working paper).
- scikit-learn: Time-series cross-validation.