def test_no_refit_multiple_metrics():
clf = DecisionTreeClassifier()
scoring = {'score_1': 'accuracy', 'score_2': 'accuracy'}
gs = dcv.GridSearchCV(clf, {'max_depth': [1, 2, 3]}, refit=False,
scoring=scoring)
gs.fit(da_X, da_y)
assert not hasattr(gs, "best_estimator_")
assert not hasattr(gs, "best_index_")
assert not hasattr(gs, "best_score_")
assert not hasattr(gs, "best_params_")
for fn_name in ('predict', 'predict_proba', 'predict_log_proba'):
with pytest.raises(NotFittedError) as exc:
getattr(gs, fn_name)(X)
assert (('refit=False. %s is available only after refitting on the '
'best parameters' % fn_name) in str(exc.value))
test_model_selection_sklearn.py 文件源码
python
阅读 23
收藏 0
点赞 0
评论 0
评论列表
文章目录