RandomizedSearchCV uses Cross-validation to find the best hyperparameters. Cross-validation splits your training set into smaller training and validation sets in order to train the model and evaluate it on unseen data.
When refit=True, the best performing model will be trained on the full training data so that it is ready for use on actual unseen data.
Sources: https://scikit-learn.org/stable/modules/generated/sklearn.model_selection.RandomizedSearchCV.html https://scikit-learn.org/1.5/modules/generated/sklearn.model_selection.cross_validate.html