Last active
June 22, 2020 16:10
-
-
Save Mehdi-Amine/2d68a835fa6346c06d9ba317b96d5adc to your computer and use it in GitHub Desktop.
Standardizing the happiness dataset
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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