np.random array code example
Example 1: random array numpy
>>> np.random.rand(3,2)
array([[ 0.14022471, 0.96360618],
[ 0.37601032, 0.25528411],
[ 0.49313049, 0.94909878]])
>>> np.random.random_integers(low=0, high=9, size=(3,2))
array([[2, 3],
[2, 3],
[6, 3]])
Example 2: random matrix python
np.random.rand(3,2)
Example 3: numpy generate random 2d array
import numpy as np
a=np.random.rand(3,3)
print(a)
Example 4: numpy randn with a shape of another array
a = np.zeros([2, 3])
print(a.shape)
b = np.random.randn(*a.shape)
print(b.shape)
Example 5: np.random.rand()
df = pd.read_csv('file_location')
mask = np.random.rand(len(df)) < 0.8
train = df[mask]
test = df[~mask]