Skip to content

Instantly share code, notes, and snippets.

@Mehdi-Amine
Last active June 22, 2020 16:10
Show Gist options
  • Save Mehdi-Amine/2d68a835fa6346c06d9ba317b96d5adc to your computer and use it in GitHub Desktop.
Save Mehdi-Amine/2d68a835fa6346c06d9ba317b96d5adc to your computer and use it in GitHub Desktop.
Standardizing the happiness dataset
from sklearn.preprocessing import StandardScaler
std_scaler = StandardScaler()
# fitting the standardscaler on the training set. Then transforming the training set
train_set_std = std_scaler.fit_transform(train_set[:,:2])
train_set_std = np.concatenate((train_set_std, train_set[:,-2:]), axis=1)
# ensuring that we only transform without fitting the validation set
valid_set_std = std_scaler.transform(valid_set[:,:2])
valid_set_std = np.concatenate((valid_set_std, valid_set[:,-2:]), axis=1)
# we repeat the same for test_set as we did for valid_set
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment