是否可以将网格搜索与外部定义的评分函数一起使用?
Is it possible to use Grid Search with an externally defined scoring function?
我定义了一个外部评分函数来确定手写数字的聚类准确性,但无法弄清楚如何将该函数与 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
returns 一个新函数,它接受一个函数作为参数。所以这应该有效:
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)
我定义了一个外部评分函数来确定手写数字的聚类准确性,但无法弄清楚如何将该函数与 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
returns 一个新函数,它接受一个函数作为参数。所以这应该有效:
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)