为什么我会收到错误“'SequentialFeatureSelector' 对象没有属性 'predict'”?

问题描述

我正在尝试在 Python 中进行顺序特征选择,并想通过 gridsearchcv 选择特征数量,有人可以帮助我理解为什么会发生这种情况吗?

X_SFS=X_train_normed
numbers = [x for x in range(1,19)]

svc = SVC(kernel='rbf',gamma=0.1,C = 10)

sfs = SequentialFeatureSelector(estimator=svc)

param_grid = [{'k_features':numbers}]

search = gridsearchcv(sfs,param_grid,cv=StratifiedKFold(5,shuffle=False),scoring='f1_macro')
search.fit(X_SFS,y_train)
svm_params.append(search.best_params_)
features_bool.append(search.best_estimator_.named_steps['sfs'].get_support())
scores.append(search.best_score_)

以上抛出错误

AttributeError: 'SequentialFeatureSelector' object has no attribute 'predict'

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)