Menu

Overfitting, Leakage, and Responsible Modelling

Lesson 5: Overfitting, Leakage, and Responsible Modelling

What is overfitting?

Overfitting happens when a model learns noise or accidental details in the training data instead of patterns that generalise.

Condition

Training performance

Test performance

UnderfittingPoorPoor
Good fitGoodGood (similar to training)
OverfittingExcellentMuch worse

Ways to reduce overfitting:

  • Use simpler models or fewer features
  • Use regularisation (e.g., Ridge, Lasso)
  • Limit model complexity (e.g., tree depth)
  • Get more training data
  • Use cross-validation to check stability

What is data leakage?

Leakage occurs when information unavailable at prediction time enters training or evaluation.

Leakage type

Example

Target leakageUsing "cancellation date" to predict whether a customer will cancel
Future informationUsing next month's sales as a feature for this month's forecast
Train-test contaminationScaling or imputing using the full dataset before splitting
Duplicate recordsThe same customer appears in both training and test sets
Proxy leakageUsing "refund issued" to predict "order complaint"

Leakage produces unrealistically good test scores that collapse in real use.

Ways to reduce risk

Practice

How it helps

Split before any preprocessingPrevents test information leaking into training
Use pipelines (e.g., scikit-learn Pipeline)Keeps preprocessing inside each training fold
Time-based splits for temporal dataPreserves chronological order
Ask "would I know this at prediction time?" for each featureCatches target leakage
Compare with a simple baselineSuspiciously large gains suggest leakage
Group splitsKeeps the same customer out of both train and test

Responsible use

Concern

Questions to ask

PrivacyDo we need personal data? Is its use permitted?
FairnessDoes performance differ across groups (gender, region, age)?
BiasDoes historical data reflect past unfair decisions?
ExplainabilityCan we explain why the model made a prediction?
ConsequencesWhat happens when the model is wrong?
OversightIs there human review or an appeal process for significant decisions?
MonitoringWill we detect when performance drifts over time?

Ensure human review or an appeal process exists when decisions significantly affect people, such as loans, hiring, or insurance.

Key takeaways

  • A technically strong score is not enough.
  • The model must:
    • Use information available at the right time
    • Work on realistic new data
    • Support a responsible decision process
  • Monitor models after deployment; data and behaviour change (drift).

Data Analytics Tutorial



Learn via Video Course

Data Analysis and Processing with Python using Pandas - Data Science Course Logo

Data Analysis and Processing with Python using Pandas - Data Science Course

5 hrs



Get in Touch For Details