Skip to content

Instantly share code, notes, and snippets.

@Mehdi-Amine
Last active April 26, 2020 15:08
Show Gist options
  • Save Mehdi-Amine/dee046527cb8a9ae117b37e5cbdd5478 to your computer and use it in GitHub Desktop.
Save Mehdi-Amine/dee046527cb8a9ae117b37e5cbdd5478 to your computer and use it in GitHub Desktop.
dx1_standardized = (dx_train[:,0] - dx_train[:,0].mean()) / dx_train[:,0].std()
dx2_standardized = (dx_train[:,1] - dx_train[:,1].mean()) / dx_train[:,1].std()
dx_train_standardized = np.concatenate((dx1_standardized.reshape(-1,1), dx2_standardized.reshape(-1,1)), axis=1)
dy_train_with_standardized_x = (dx1_standardized + dx2_standardized * 0.5)
training_data_std = list(zip(dx_train_standardized, dy_train_with_standardized_x))
# Printing the first 5 rows:
print(f"Standardized X: \n{dx_train_standardized[:5]} \nStandardized y: \n{dy_train_with_standardized_x[:5]}")
'''
Out:
Standardized X:
[[-0.55691098, 1.55759807],
[ 0.80869448, 0.06826127],
[-0.38621029, 1.72307993],
[-0.55691098, 1.3921162 ],
[ 0.12589175, 0.06826127]]
y:
[0.22188806, 0.84282512, 0.47532967, 0.13914712, 0.16002239]
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment