Using random.seed
:
np.random.seed(0)
np.random.rand(5)
# Out: array([ 0.5488135 , 0.71518937, 0.60276338, 0.54488318, 0.4236548 ])
By creating a random number generator object:
prng = np.random.RandomState(0)
prng.rand(5)
# Out: array([ 0.5488135 , 0.71518937, 0.60276338, 0.54488318, 0.4236548 ])