38. Overfitting and Underfitting in Machine Learning
38.1 Too Fit vs Too Weak
Why. A notebook can look brilliant on training rows and fail on next week’s live orders. That gap has names: overfitting and underfitting.
What. Overfitting = the model memorised training noise (“too fit”). Underfitting = the model is too weak to catch the real pattern (“too simple”). Both hurt new rows.
How.
Picture two students
- Overfit student: memorises last year’s exact MCQs, blanks on new wording.
- Underfit student: only learned “always tick option B.”
- Good student: learns patterns that still work on a fresh question paper (test set).
print("Overfit: train score >> test score")
print("Underfit: train and test scores both weak")
print("Healthy: both decent, gap not huge")
Ravindra Bagale's Tip
Do not feel happy just because training accuracy is 100%. Always check the test score too, because a model that only remembers the training data will do badly on new data.
Ravindra Bagale's Tip – मराठी
Training accuracy 100% पाहून लगेच खुश होऊ नका. Test score सुद्धा नेहमी तपासा, कारण जे model फक्त training data लक्षात ठेवतं ते नवीन data वर नीट काम करत नाही.
Ravindra Bagale's Tip – हिंदी
Training accuracy 100% देखकर तुरंत खुश मत हो जाओ. Test score भी हमेशा जाँचो, क्योंकि जो model सिर्फ training data याद रखता है वह नए data पर ठीक से काम नहीं करता.