# Creating a separate object for scaling test data - Not a good idea.scaler = StandardScaler();scaler.fit(X_test_imp);# Calling fit on the test data - Yikes! X_test_scaled = scaler.transform(X_test_imp) # Transforming the test data using the scaler fit on test data ... Bad!
# Join the train and test sets back togetherX_train_imp_df = pd.DataFrame(X_train_imp,columns=X_train.columns, index=X_train.index)X_test_imp_df = pd.DataFrame(X_test_imp,columns=X_test.columns, index=X_test.index)XX = pd.concat([X_train_imp_df, X_test_imp_df], axis =0) ## Don't do it! XX.shape