Could we use randomizedsearchcv during nested cross validation?
You can. Just be aware that in every iteration of the outer loop of the cross-validation, a different set of hyperparameters will be evaluated, meaning that the generalization performance (the score computed in the outer loop) does not correspond to a given set of parameters, but rather a set of optimized models.
This is similar to what we do in the Regularization of linear regression model notebook where a set of equally valid alphas
are found for RidgeCV
.
Also take into account that the computational cost increases with the number of iterations of the RandomizedSearchCV
(which should itself be increased when adding hyperparameters), so cross-validating those results will increase the required computing resources as many times as folds you evaluate.