How Can I Prevent Data Leakage When Preprocessing Data for Machine Learning in Python?
I am learning machine learning with Python and Scikit-learn, and I want to understand the correct way to preprocess datasets before training a model. I understand that data preprocessing often involves handling missing values, feature scaling, and splitting the dataset into training and testing sets. However, I am confused about whether feature scaling should be performed before or after splitting the dataset. For example: from sklearn.model_selection import train_test_split from sklearn.preprocessing import StandardScaler X_train, X_test, y_train, y_test = train_test_split( X, y, test_size=0.
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.