When using the cross_val_score of sklearn.model_selection to implement cross-validation, we also hope to add some control parameters (such as sample_weight, eval_set, eval_metric, early_stopping_rounds, etc.) during fit to improve training efficiency.
The specific implementation method is to specify the corresponding parameters in the fit_params of cross_val_score:
fit_params : dict, optional
Parameters to pass to the fit method of the estimator.
Then the estimator will pass in these parameters when calling the fit method:
try:
if y_train is None:
estimator.fit(X_train, **fit_params)
else:
estimator.fit(X_train, y_train, **fit_params)