I have recently learned about Random Search (or sklearn.model_selection.RandomizedSearchCV in Python) and was thinking about the theory behind the optimization process. In particular my question is, given that one performs Random Search on a certain algorithm (let's say random forest), what are the best hyperparameter based on? More specifically in what sense are they the "best" hyperparameters for the model? Do they maximize accuracy of the model? If not what is the (performance-)criterion that is optimized? Or is it entropy/gini?


According to the documentation, the function RandomizedSearchCV accepts a scoring string that can take any value from this table and you can even implement your own custom scorer depending on what your goal is.

The default parameter is None in which case it uses the models score function that is defined to:

Return the mean accuracy on the given test data and labels.

  • $\begingroup$ How could I change the code then, so that I can optimize my random forest to achieve the best f1-score via random search? $\endgroup$ – RazorLazor May 1 '20 at 18:20
  • $\begingroup$ If you follow my link for the table, you can see that one of the listed scoring classification function choices is called "f1", thus just pass the string 'f1' to RandomizedSearchCV along with the random forest $\endgroup$ – A Kareem May 2 '20 at 1:26
  • $\begingroup$ Perfect, thanks! $\endgroup$ – RazorLazor May 2 '20 at 9:18

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.