np random shuffle code example

Example 1: np random seed

>>> import numpy as np
>>> 
>>> np.random.seed(0)
>>> 
>>> np.random.rand(3)
array([0.5488135 , 0.71518937, 0.60276338])
>>> np.random.rand(3)
array([0.54488318, 0.4236548 , 0.64589411])
>>> 
>>> 
>>> np.random.seed(1)
>>> 
>>> np.random.rand(3)
array([4.17022005e-01, 7.20324493e-01, 1.14374817e-04])
>>> np.random.rand(3)
array([0.30233257, 0.14675589, 0.09233859])
>>> 
>>> 
>>> np.random.seed(0)
>>> 
>>> np.random.rand(3)
array([0.5488135 , 0.71518937, 0.60276338])
>>> np.random.rand(3)
array([0.54488318, 0.4236548 , 0.64589411])

Example 2: numpy randomly swap lines

>>> X = np.random.random((6, 2))
>>> X
array([[ 0.9818058 ,  0.67513579],
       [ 0.82312674,  0.82768118],
       [ 0.29468324,  0.59305925],
       [ 0.25731731,  0.16676408],
       [ 0.27402974,  0.55215778],
       [ 0.44323485,  0.78779887]])

>>> np.random.shuffle(X)
>>> X
array([[ 0.9818058 ,  0.67513579],
       [ 0.44323485,  0.78779887],
       [ 0.82312674,  0.82768118],
       [ 0.29468324,  0.59305925],
       [ 0.25731731,  0.16676408],
       [ 0.27402974,  0.55215778]])