You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[FAQ] Why should missing-value mean be calculated only from the training data? #435
Why should I calculate the mean for filling missing values using only the training dataset instead of the full dataset?
Answer
The mean should be calculated only from the training data because the validation and test datasets should not be used when preparing the training data.
If we calculate the mean using the full dataset, information from the validation or test data can leak into the training process. This is called data leakage.
Activity
alexeygrigorev commentedon Oct 14, 2026
Thanks! We added this explanation, including reusing the training mean for validation and test and why that avoids data leakage, to the existing FAQ entry: https://github.com/DataTalksClub/faq/blob/main/_questions/machine-learning-zoomcamp/module-2-homework/003_af50bd4d07_homework-q3-meaning-of-mean.md