Underfitting and Overfitting
A model that is too simple underfits: it misses the pattern. A model that is too flexible overfits: it memorises the noise in the training data and does badly on new data. The sign is a high training score with a much lower test score.
A decision tree with no depth limit can memorise everything. Limiting max_depth keeps it honest.
Examplepython
Quick check
A model scores 0.99 on training data and 0.55 on test data. This suggests...
Your turn: write the code
Train a tree with max_depth=3 and print its test score rounded to 2 decimals.
Finish the quick check (and any code exercise) to complete this lesson, or mark it done yourself.
Tip: use the left and right arrow keys to move between lessons.