While trying to evaluate my Ridge Regression model and using GridSearchCV to find the best parameter. I noticed that the best estimator changes every time I change my random_state. With this in mind how do I choose the most optimal hyper parameter to implement my model.

  • 1
    $\begingroup$ Which hyperparameter(s) are you tuning? Are the values radically different depending on random_state, or are they mostly similar with small variations? $\endgroup$ – zachdj Apr 20 at 16:30
  • $\begingroup$ @zachdj I am trying to tune the alpha parameter in Ridge Regression. As I run GridSearchCV with different random_states for Kfold I get really varying best_estimator_ value for alpha ranging from 3 to 25. I am getting a r2 score between 0.6 to 0.7. I think I should mention that my data is pretty small (300 entries). Is that $\endgroup$ – Ahmed Jyad Apr 21 at 16:27

I am assuming, you are taking about the random_state of the Model, not the GridSearch (as it doesn't have a random_state) RandomizedSearchCV do need one.

A random state defines a starting point for an underlying random process.

With an ideal model, the difference should be very small. Though it will be. If it is high, it means there is some Outlier data point/pattern due to which certain value is favoured.

Ignore - if small

If it is large for a specific value
- Check the data
- Increase K for the CrossVal

From another Stackexchange Question

random state values which performed well in the validation set do not correspond to those which would perform well in a new, unseen test set.

From MachineLearning Mastery

We can increase k and build even more models, as long as the data within each fold remains representative of the problem

Stochastic Process
Randomness in ML

| improve this answer | |
  • $\begingroup$ The random_state is in the cv attribute of GridSearchCV. I used Kfold to shuffle my data. $\endgroup$ – Ahmed Jyad Apr 21 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.