NumPy Random | seed method
seed(~) method is used to generate reproducible results where randomness is involved.
The seed to set - usually we just set an integer like
To set a seed for reproducible results:
import numpy as npnp.random.seed(42)print(np.random.rand(4))[0.37454012 0.95071431 0.73199394 0.59865848]
Regardless of how many times you run this script, the generated random sample is always the same. This is true regardless of the environment.