Python random state in data set splitting

I am a little new to python. can anyone tell me why we set the random state to zero in splitting the train and test suite.

X_train, X_test, y_train, y_test = \
    train_test_split(X, y, test_size=0.30, random_state=0)

I saw situations like this when a random state is set to unity!

X_train, X_test, y_train, y_test = \
    train_test_split(X, y, test_size=0.30, random_state=1)

What is the consequence of this random state during cross-validation?

+7
source share
3 answers

, random_state 0 1 . , , . , , random_state=42 scikit, .

random_state, , , . , :

random_state - None np.random, RandomState.

random_state , RandomState.

random_state - RandomState, .

. random_state , , . - , , . .

+15

Random_state , . random_state. , . 0 no, random_state, . : , random_state=0 . , random_state=5 random_state=0 . 0 . random_state=None .

,

+1

If you do not mention random_state in the code, then whenever you execute your code, a new random value is generated, and the train and test datasets will have different values ​​each time.

However, if you use a specific value for random_state (random_state = 1 or any other value) every time the result is the same, that is, the same values ​​in the train and test datasets.

0
source

Source: https://habr.com/ru/post/1669526/


All Articles