random_state, please help | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

random_state, please help

I need to understand what exactly the random_state parameter does in the model from my understanding its just a value that i should keep it fixed in the train_test_split and in the model object so it does not give me a random accuracy score everytime. so my question is everytime i change the random state, my model accuracy gets better or worst, so i decided to put my model in a loop to find a random_state value that gives the highest accuracy to my model, is that a right thing to do or not for example: scores = [] for n in range(1, 201): X_train, X_test, y_train, y_test = train_test_split(X, y, train_size=0.8, test_size=0.2, random_state=n) model = MLPClassifier(random_state=n) model.fit(X_train, y_train) scores.append(model.score(X_test, y_test)) print(scores)

1st Nov 2022, 7:29 PM
Wissam Metwaee
Wissam Metwaee - avatar
1 Answer