Scaling Data - Standard Scaler

PHOTO EMBED

Wed Mar 16 2022 09:40:53 GMT+0000 (UTC)

Saved by @abhin__dev

# Fit the scaler on the training data
from sklearn.preprocessing import StandardScaler
scaler = StandardScaler()
scaler.fit(df_train)
features = df_train.columns

# Scale the training, test, and validation sets
features = df_train.columns

df_train[features] = scaler.transform(df_train[features])
df_val[features] = scaler.transform(df_val[features])
df_test[features] = scaler.transform(df_test[features])

df_train.head()
content_copyCOPY