【发布时间】:2019-12-13 15:30:36
【问题描述】:
我已经阅读了几页,但需要有人帮助解释如何使它工作。
我正在使用TPOTRegressor() 来获得最佳管道,但我希望能够从那里绘制它返回的管道的.feature_importances_:
best_model = TPOTRegressor(cv=folds, generations=2, population_size=10, verbosity=2, random_state=seed) #memory='./PipelineCache', memory='auto',
best_model.fit(X_train, Y_train)
feature_importance = best_model.fitted_pipeline_.steps[-1][1].feature_importances_
我在 Github 上的一个现已关闭的问题中看到了这种设置,但目前我得到了错误:
Best pipeline: LassoLarsCV(input_matrix, normalize=True)
Traceback (most recent call last):
File "main2.py", line 313, in <module>
feature_importance = best_model.fitted_pipeline_.steps[-1][1].feature_importances_
AttributeError: 'LassoLarsCV' object has no attribute 'feature_importances_'
那么,我如何从最优管道中获得这些特征重要性,而不管它落在哪一个?或者这甚至可能吗?或者有人有更好的方法来尝试从 TPOT 运行中绘制特征重要性?
谢谢!
更新
为了澄清,特征重要性的含义是确定数据集的每个特征 (X) 在确定预测 (Y) 标签中的重要性,使用条形图来绘制每个特征在提出时的重要性级别它的预测。 TPOT 不直接这样做(我不这么认为),所以我想我会抓住它提出的管道,在训练数据上重新运行它,然后以某种方式使用 .feature_imprtances_ 然后能够绘制特征重要性的图表,因为这些都是我正在使用的 sklearn 回归器?
【问题讨论】:
标签: python scikit-learn regression pipeline tpot