Skip to content

Instantly share code, notes, and snippets.

@Mehdi-Amine
Last active April 26, 2020 14:58
Show Gist options
  • Save Mehdi-Amine/dc78714366a3aed1d1f9204e0b08e80a to your computer and use it in GitHub Desktop.
Save Mehdi-Amine/dc78714366a3aed1d1f9204e0b08e80a to your computer and use it in GitHub Desktop.
dx1_normalized = (dx_train[:,0] - dx_train[:,0].min()) / (dx_train[:,0].max() - dx_train[:,0].min())
dx2_normalized = (dx_train[:,1] - dx_train[:,1].min()) / (dx_train[:,1].max() - dx_train[:,1].min())
dx_train_normalized = np.concatenate((dx1_normalized.reshape(-1,1), dx2_normalized.reshape(-1,1)), axis=1)
dy_train_with_normalized_x = (dx1_normalized + dx2_normalized * 0.5)
training_data_normd = list(zip(dx_train_normalized, dy_train_with_normalized_x))
# Printing the first 5 rows:
print(f"Normalized X: \n{dx_train_normalized[:5]} \ny: \n{dy_train_with_normalized_x[:5]}")
'''
Out:
Normalized X:
[[0.3 , 0.95],
[0.7 , 0.5],
[0.35, 1. ],
[0.3 , 0.9],
[0.5 , 0.5]]
y:
[0.775, 0.95 , 0.85 , 0.75 , 0.75]
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment