Skip to content
Edition NigeriaGlobal
Country: Mexico

You are in the Mexico edition. Type your country to switch.

The Americas

Set up your profile

You are learning in the Mexico edition, with examples in pesos and from Mexico.

Financial Data Lab · Lesson 7 of 8

Lab 7: watching a model overfit

This lab fits models of rising complexity to invented data and watches the error on the training data fall while the error on held-back test data first falls and then rises. That turn is overfitting. It also shows how trying many rules on one data set produces a winner by luck alone.

Advanced10 min read5 steps

This lesson is complete in writing. A video for it is on its way.

What you will learn

  • By the end you can split data into training and test parts, fit models of rising complexity and compare their errors.
  • You can read a table of training and test error and pick the point where overfitting begins.
  • You can work out the chance that at least one of many random rules looks significant by luck.
  • You can explain why financial data must be split by time and why a final test set should be used only once.

Key terms in this lesson

Overfitting
Tuning a model or strategy so closely to past data that it captures noise and fails on new data.
Training error
How badly a model fits the data it was built on. It always falls as a model becomes more complex, so on its own it says little about future performance.
Test error
How badly a model fits data held back from building it. It is the honest measure of how well the model is likely to do on new data.
Multiple testing
The problem that testing many ideas at a fixed threshold makes some pass by luck. The more tests, the higher the threshold each should meet.
Data snooping
Testing many ideas on the same data and reporting the best ones, which makes results found by chance look like real effects.

Step 1 of 5

The experiment

Opening this step…

Step 2 of 5

Fitting models of rising complexity

This step opens when you finish the one above.

Step 3 of 5

Reading the pattern

This step opens when you finish the one above.

Step 4 of 5

Trying many rules: winning by luck

This step opens when you finish the one above.

Step 5 of 5

Splitting financial data properly

This step opens when you finish the one above.

Key takeaways

The key takeaways open when you finish every step.

Lesson quiz

6 questions. You need 85% to pass.

The quiz opens when you finish every step.

Read first

Stockertim Learn is education. It explains how investing works and never recommends buying or selling anything.

Up next

Financial data & analyticsLab 8: writing the model card an…Read nowLab 8: writing the model card and a reproducible notebookFinancial data & analytics · Advanced · 15 minFinancial data & analyticsBuilding a three-statement modelRead nowBuilding a three-statement modelFinancial data & analytics · Advanced · 15 minFinancial data & analyticsBuilding a DCF in a modelRead nowBuilding a DCF in a modelFinancial data & analytics · Advanced · 15 minFinancial data & analyticsScenarios and sensitivities in a…Read nowScenarios and sensitivities in a modelFinancial data & analytics · Advanced · 15 minAI & securityLeakage, look-ahead bias and wal…Read nowLeakage, look-ahead bias and walk-forward validationAI & security · Advanced · 15 minFinancial data & analyticsSignificance and data-miningRead nowSignificance and data-miningFinancial data & analytics · Intermediate · 15 minAdvanced strategies & derivativesBacktesting pitfalls: why past r…Read nowBacktesting pitfalls: why past results misleadAdvanced strategies & derivatives · Advanced · 15 minFinancial data & analyticsLab 6: a sentiment classifier on…Read nowLab 6: a sentiment classifier on sample headlinesFinancial data & analytics · Advanced · 15 minFinancial data & analyticsCommon financial modelling errorsRead nowCommon financial modelling errorsFinancial data & analytics · Advanced · 15 minFinancial data & analyticsChecking a financial modelRead nowChecking a financial modelFinancial data & analytics · Advanced · 15 minFinancial data & analyticsLab 5: cleaning corporate action…Read nowLab 5: cleaning corporate actions in codeFinancial data & analytics · Advanced · 15 minTrading: risk, costs and processBacktesting properly: out-of-sam…Read nowBacktesting properly: out-of-sample tests, walk-forward, multiple testing and overfittingTrading: risk, costs and process · Advanced · 15 min
English