Skip to content

Instantly share code, notes, and snippets.

@thijsessens
Created June 30, 2020 04:54
Show Gist options
  • Save thijsessens/f2ac3dc68ef8a349a723444cb012c821 to your computer and use it in GitHub Desktop.
Save thijsessens/f2ac3dc68ef8a349a723444cb012c821 to your computer and use it in GitHub Desktop.
Inverse StandardScaler example
#load StandardScaler
from sklearn.preprocessing import StandardScaler
#create fake y_train dataframe
y_train = pd.DataFrame ([1,2,3,4], columns =['y_train'])
scalery = StandardScaler().fit(y_train)
#transform the y_test data
y_test = pd.DataFrame ([1,2,3,4], columns =['y_test'])
y_test = scalery.transform(y_test)
# print transformed y_test
print("this is the scaled array:",y_test)
#inverse the y_test data back to 1,2,3,4
y_new = pd.DataFrame (y_test, columns =['y_new'])
y_new_inverse = scalery.inverse_transform(y_new)
# print inversed to original y_test
print("this is the inversed array:",y_new_inverse)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment