Reputation: 100
Is there a way to pass the current candidate model as an input to a custom scoring function?
I am looking for something similar to thecross_val_score
method, where clf
is one of the inputs.
Passing the model as an extra argument does not work since the copy of the candidate is model is not carried in the scoring procedure. What I get instead is an unfitted model with the default parameters.
Upvotes: 2
Views: 567
Reputation: 12582
Yes, that's how scoring works in GridSearchCV
: the scoring
parameter can be a callable, with signature (estimator, X, y)
. The search fits a copy of the estimator on training folds, and passes that into your scorer together with the test fold data. See the User Guide.
Upvotes: 2