I'd like to make a custom scoring function involving classification probabilities as follows:
def custom_score(y_true, y_pred_proba):
error = ...
return error
my_scorer = make_scorer(custom_score, needs_proba=True)
gs = GridSearchCV(estimator=KNeighborsClassifier(),
param_grid=[{'n_neighbors': [6]}],
cv=5,
scoring=my_scorer)
Is there any way to pass the estimator, as fit by GridSearch with the given data and parameters, to my custom scoring function? Then I could interpret the probabilities using estimator.classes_
For example:
def custom_score(y_true, y_pred_proba, clf):
class_labels = clf.classes_
error = ...
return error
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…