Where the Leak Shows

Machine Learning in CodeMedium+10 XP+10

Where the Leak Shows

A leaky scaler is fitted on all rows, test rows included. Usually it learns almost the same numbers as an honest one, but not always. Find the columns where the leak actually changed something.

Task: write leaky_columns(name, test_size, seed). name is "iris", "wine" or "breast_cancer".

  • Load the dataset as X and y, and split with train_test_split(X, y, test_size=test_size, random_state=seed).
  • Fit one MinMaxScaler on X_train (honest) and another on the whole of X (leaky).
  • Return the names of the columns where the leaky scaler's learned minimum or maximum differs from the honest one, in the dataset's column order.

Examples

name = "iris"
test_size = 0.25
seed = 0
returns ['petal length (cm)']
name = "wine"
test_size = 0.2
seed = 1
returns ['malic_acid', 'alcalinity_of_ash', 'nonflavanoid_phenols', 'hue']

Hints

Solve it to unlock the solution

Once your code passes every test, a reference solution shows up here so you can compare it with yours.

solution.py
CtrlEnterto run