我定义了外部评分函数,以确定手写数字的群集精度,但无法弄清楚如何与GridSearchCV结合使用该函数。
s = GridSearchCV(estimator = pipe_cl,
param_grid = param_distributions,
scoring = my_scorer,
n_jobs=-1)
gs.fit(X_train, y_train)
y_pred_km = gs.predict(X_test)
my_scorer = make_scorer(clustering_accuracy_score(y_test, y_pred_km))
make_scorer
返回一个新函数,它作为参数为参数。所以这应该有效:
my_scorer = make_scorer(clustering_accuracy_score)
gs = GridSearchCV(estimator = pipe_cl,
param_grid = param_distributions,
scoring = my_scorer,
n_jobs=-1)
gs.fit(X_train, y_train)