Skip to content

Instantly share code, notes, and snippets.

@dvgodoy
Created July 13, 2020 18:28
Show Gist options
  • Save dvgodoy/268359171a95daba4cd496743dd08200 to your computer and use it in GitHub Desktop.
Save dvgodoy/268359171a95daba4cd496743dd08200 to your computer and use it in GitHub Desktop.
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler(with_mean=True, with_std=True)
# We use the TRAIN set ONLY to fit the scaler
scaler.fit(x_train)
# Now we can use the already fit scaler to TRANSFORM
# both TRAIN and VALIDATION sets
scaled_x_train = scaler.transform(x_train)
scaled_x_val = scaler.transform(x_val)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment