提问人:Cherechukwu Ezeh 提问时间:11/14/2023 更新时间:11/14/2023 访问量:7
访问 imblearn EasyEnsembleClassifier 的feature_importances_
Accessing the feature_importances_ of the imblearn EasyEnsembleClassifier
问:
我是Chere,我是新来的。 请问如何在以 AdaBoost Classifier 作为估计器的管道中从 imblearn 获取 EasyEnsembleClassifier 的feature_importances_? 我的管道如下所示:
from sklearn.pipeline import make_pipeline, Pipeline
from sklearn.ensemble import AdaBoostClassifier
from imblearn.ensemble import EasyEnsembleClassifier
pipe6 = Pipeline([ ('ct_step', ct), ('model', EasyEnsembleClassifier(n_estimators=10, replacement=True, sampling_strategy=0.005, base_estimator=AdaBoostClassifier())) ]).
我试过了这个:
pipe6.named_steps['model'].feature_importances_
fd6 = pd.DataFrame({'Feature_names':pipe6.named_steps['ct_step'].get_feature_names_out(),'Importances':pipe6.named_steps['model'].base_estimator.feature_importances_})
fd6['Importances'] = fd6['Importances'].apply(lambda x: format(x, '.5f'))
fd6 = fd6.drop(fd6[fd6.Importances < '0.00001'].index )
fd6 = fd6.sort_values(by='Importances', ascending=False)
fd6 = fd6.replace({"pp_num__": "", "pp_cat__": ""}, regex=True)
1
显示要素重要性表
print('FEATURE IMPORTANCE TABLE')
print(fd6)
但是继续得到 AttributeError: Pipeline has no object attribute 'feature_importances_ 我需要帮助
答: 暂无答案
评论