且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何从 Sklearn 管道中提取特征重要性

更新时间:2023-02-27 10:46:17

啊,是的.

您列出要检查估算器的步骤:

You list identify the step where you want to check the estimator:

例如:

pipeline.steps[1]

哪个返回:

('predictor',
 RandomForestClassifier(bootstrap=True, class_weight=None, criterion='gini',
             max_depth=None, max_features='auto', max_leaf_nodes=None,
             min_samples_leaf=1, min_samples_split=2,
             min_weight_fraction_leaf=0.0, n_estimators=50, n_jobs=2,
             oob_score=False, random_state=None, verbose=0,
             warm_start=False))

然后您可以直接访问模型步骤:

You can then access the model step directly:

pipeline.steps[1][1].feature_importances_

pipeline.steps[1][1].feature_importances_