Question 3
You’re working with a dataset that consists of training data (‘train_data’) and test data (‘test_data’). The dataset contains both numerical and categorical features. You decide to employ a combination of ‘StandardScaler’ (for numerical columns) and ‘OneHotEncoder’ (for categorical columns) from ‘scikit-learn’ using the ‘ColumnTransformer’ utility. Which of the following actions is MOST likely to introduce data leakage or potential modeling issues?
You utilize ‘fit_transform’ on ‘train_data’ and then ‘transform’ on ‘test_data’ using the ‘ColumnTransformer’.
After observing a new category in the test data that was not present in the training data, you set the ‘handle_unknown’ parameter to ’ignore’ in ‘OneHotEncoder’.
You first apply ‘fit’ on the ‘test_data’ and then ‘transform’ on ‘train_data’ using the ‘ColumnTransformer’.
Before using ‘ColumnTransformer’, you independently apply ‘fit_transform’ to ‘train_data’ for both ‘StandardScaler’ and ‘OneHotEncoder’.