Skip to content

Instantly share code, notes, and snippets.

@cydal
Created November 26, 2020 13:12
Show Gist options
  • Save cydal/3d1b0d63b15fa5b0090d9d19ad0cb48a to your computer and use it in GitHub Desktop.
Save cydal/3d1b0d63b15fa5b0090d9d19ad0cb48a to your computer and use it in GitHub Desktop.
scaler_features = StandardScaler().fit(build_df[build_df.columns.values[:-1]])
scaled_features = scaler_features.transform(build_df[build_df.columns.values[:-1]])
scaler_label = StandardScaler().fit(np.array(build_df[build_df.columns.values[-1]]).reshape(-1, 1))
scaled_label = scaler_label.transform(np.array(build_df[build_df.columns.values[-1]]).reshape(-1, 1))
### Split data using train proportion of 0.7
train_size = int(scaled_features[:, :-1].shape[0] * 0.7)
X_train, y_train = scaled_features[:train_size, :-1], scaled_label[:train_size, :]
X_test, y_test = scaled_features[train_size:, :-1], scaled_label[train_size:, :]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment