scikit-learn random state in splitting dataset

后端 未结 9 1932
无人共我
无人共我 2020-12-05 09:12

Can anyone tell me why we set random state to zero in splitting train and test set.

X_train, X_test, y_train, y_test = \\
    train_test_split(X, y, test_size         


        
9条回答
  •  南方客
    南方客 (楼主)
    2020-12-05 09:59

    The random_state splits a randomly selected data but with a twist. And the twist is the order of the data will be same for a particular value of random_state.You need to understand that it's not a bool accpeted value. starting from 0 to any integer no, if you pass as random_state,it'll be a permanent order for it. Ex: the order you will get in random_state=0 remain same. After that if you execuit random_state=5 and again come back to random_state=0 you'll get the same order. And like 0 for all integer will go same. How ever random_state=None splits randomly each time.

    If still having doubt watch this

提交回复
热议问题