How to spot it
- A large gap between train and test metrics, for example Gini 0.72 in training and 0.45 in testing.
- A learning curve where the training score stays far above the validation score.
- Results that change a lot between cross-validation folds.
- Many variables or very deep trees for a small amount of data.
Worked example (illustrative figures)
| Model | Gini in training | Gini in testing |
|---|---|---|
| Deep trees, 300 variables | 0.72 | 0.45 |
| Regularized, 40 variables | 0.52 | 0.49 |
The second model looks worse in training but is better where it matters: on applicants it has never seen.
How to prevent it
- Regularization: ridge, lasso or elastic net in linear models; depth, leaf size and learning rate limits in tree models.
- Fewer, better variables.
- Cross-validation when data is limited, and an out-of-time test when the model will be used in the future.
- More data, for example by adding alternative data instead of adding more derived variables.
How Thorcast.AI helps
- The evaluation tab shows metrics for train, test and train + test side by side, plus a learning curve.
- You can split by random percentage, by date vintages or with cross-validation (2 to 20 folds) when there are fewer rows.
- AutoML includes regularized logistic regressions and tuned tree models, and MJÖ flags metrics that look too good to be true.
Frequently asked questions
What is the difference between overfitting and underfitting?
Overfitting learns too much of the training data, including noise; underfitting learns too little and misses real patterns. Both perform poorly on new data.
Is a small gap between train and test normal?
Yes. Some gap is expected; what matters is that it is small and that test performance is stable over time.
Does more data always fix overfitting?
It helps a lot, but the variables and the model's complexity still need to match the size and quality of the data.