我定义了一个外部评分函数来确定手写数字的集群精度,但无法弄清楚如何将该函数与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))
答案 0 :(得分:0)
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)