Skip to content

Instantly share code, notes, and snippets.

@Mehdi-Amine
Last active April 26, 2020 12:24
Show Gist options
  • Save Mehdi-Amine/41e04f8faa8808ac655640f7c3ea55e2 to your computer and use it in GitHub Desktop.
Save Mehdi-Amine/41e04f8faa8808ac655640f7c3ea55e2 to your computer and use it in GitHub Desktop.
Generating a dataset to work with. The labels are the first column plus the product of the second column and 0.5
import numpy as np
np.random.seed(42)
dx = np.random.randint(low=-10, high=11, size=(100,2)).astype(float)
dy = (dx[:,0] + dx[:,1]*0.5)
dx_train, dx_test, dy_train, dy_test = dx[:80], dx[80:], dy[:80], dy[80:]
training_data = list(zip(dx_train, dy_train))
testing_data = list(zip(dx_test, dy_test))
print(f"The first 5 rows of the dataset:\n{np.concatenate((dx, dy.reshape(-1,1)), axis=1)[:5]}")
'''
Out:
The first 5 rows of the dataset:
[[-4. 9. 0.5]
[ 4. 0. 4. ]
[-3. 10. 2. ]
[-4. 8. 0. ]
[ 0. 0. 0. ]]
'''
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment