What is the use of numpy.random.seed() Does it make any difference?

前端 未结 1 1471
既然无缘
既然无缘 2021-01-21 10:07

I have a dataset named \"admissions\".

I am trying to carry out holdout validation on a simple dataset. In order to carry out permutation on the index of the dataset, I

相关标签:
1条回答
  • 2021-01-21 10:37

    You don't need to initialize the seed before the random permutation, because this is already set for you. According to the documentation of RandomState:

    Parameters:
    seed : {None, int, array_like}, optional Random seed initializing the pseudo-random number generator. Can be an integer, an array (or other sequence) of integers of any length, or None (the default). If seed is None, then RandomState will try to read data from /dev/urandom (or the Windows analogue) if available or seed from the clock otherwise.

    The concept of seed is relevant for the generation of random numbers. You can read more about it here.

    To integrate this answer with a comment (from JohnColeman) to your question, I want to mention this example:

    >>> numpy.random.seed(0)
    >>> numpy.random.permutation(4)
    array([2, 3, 1, 0])
    >>> numpy.random.seed(0)
    >>> numpy.random.permutation(4)
    array([2, 3, 1, 0])
    
    0 讨论(0)
提交回复
热议问题