[机器学习 - 算法调用] 随机森林 sklearn.RandomForestCLassifier/ Regressor

特征重要性

feature_importances_

Return the feature importances (the higher, the more important the feature).

Returns:

feature_importances_ : array, shape = [n_features]

The values of this array sum to 1, unless all trees are single node trees consisting of only the root node, in which case it will be an array of zeros.

这里返回的特征重要性是一个和模型输入特征等长的array,不会改变原有特征的顺序,即模型fit的train set里特征的顺序,和输出的特征重要性的数值顺序是一致的,一一对应的。

features = list(train.columns)

random_forest = RandomForestClassifier()
random_forest.fit(train, train_label)
feature_importance_values = random_forest.feature_importances_

feature_importance = pd.Dataframe({'Feature': features, 'Importance': feature_importance_values})

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值