Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from sklearn.datasets import load_boston
- from sklearn.model_selection import train_test_split
- def standardize(x):
- mean_x = x.mean(axis=0)
- std_x = x.std(axis=0)
- return (x - mean_x)/std_x
- boston = load_boston()
- X = boston.data
- y = boston.target
- X_std = standardize(X)
- x_0 = np.ones(X.shape[0]).reshape(-1, 1)
- X_std = np.hstack([x_0, X_std])
- y_std = standardize(y)
- X_train, X_test, y_train, y_test = train_test_split(X_std, y_std, test_size=0.3, random_state=42)
- print(X_train.shape)
- print(X_test.shape)
- print(y_train.shape)
- print(y_test.shape)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement