AttributeError: 'RandomizedSearchCV' object has no attribute 'grid_scores_'
AttributeError: 'RandomizedSearchCV' object has no attribute 'grid_scores_'
当我尝试这段代码时:
import sklearn_crfsuite
from sklearn.model_selection import RandomizedSearchCV
f1_scorer = make_scorer(metrics.flat_f1_score,
average='weighted', labels=labels)
params_space = {
'c1': scipy.stats.expon(scale=0.5),
'c2': scipy.stats.expon(scale=0.05),
}
crf = sklearn_crfsuite.CRF(
algorithm='lbfgs',
max_iterations=100,
all_possible_transitions=True)
rs = RandomizedSearchCV(crf, params_space,
cv=3,
verbose=1,
n_jobs=-1,
n_iter=50,
scoring=f1_scorer)
rs.fit(X_train, y_train)
_x = [s.parameters['c1'] for s in rs.grid_scores_]
_y = [s.parameters['c2'] for s in rs.grid_scores_]
_c = [s.mean_validation_score for s in rs.grid_scores_]
我遇到错误:
AttributeError: 'RandomizedSearchCV' object has no attribute 'grid_scores_'
sklearn-crfsuite 版本 = 0.3.6
grid_scores_
已弃用,现在使用 cv_results_
。
cv_results_ 的实现与 grid_scores_
有很大不同
要提取正确的 _x、_y 和 _c 集,下面的代码应该可以工作
_x = [s['c1'] for s in rs.cv_results_['params']]
_y = [s['c2'] for s in rs.cv_results_['params']]
_c = [s for s in rs.cv_results_['mean_train_score']]
当我尝试这段代码时:
import sklearn_crfsuite
from sklearn.model_selection import RandomizedSearchCV
f1_scorer = make_scorer(metrics.flat_f1_score,
average='weighted', labels=labels)
params_space = {
'c1': scipy.stats.expon(scale=0.5),
'c2': scipy.stats.expon(scale=0.05),
}
crf = sklearn_crfsuite.CRF(
algorithm='lbfgs',
max_iterations=100,
all_possible_transitions=True)
rs = RandomizedSearchCV(crf, params_space,
cv=3,
verbose=1,
n_jobs=-1,
n_iter=50,
scoring=f1_scorer)
rs.fit(X_train, y_train)
_x = [s.parameters['c1'] for s in rs.grid_scores_]
_y = [s.parameters['c2'] for s in rs.grid_scores_]
_c = [s.mean_validation_score for s in rs.grid_scores_]
我遇到错误:
AttributeError: 'RandomizedSearchCV' object has no attribute 'grid_scores_'
sklearn-crfsuite 版本 = 0.3.6
grid_scores_
已弃用,现在使用 cv_results_
。
cv_results_ 的实现与 grid_scores_
有很大不同要提取正确的 _x、_y 和 _c 集,下面的代码应该可以工作
_x = [s['c1'] for s in rs.cv_results_['params']]
_y = [s['c2'] for s in rs.cv_results_['params']]
_c = [s for s in rs.cv_results_['mean_train_score']]