简体   繁体   English

在将分类变量转换为虚拟变量后,如何从 sklearn api 中找到特征重要性?

[英]How can I find Feature importance from sklearn api, after I have converted my categorical variables into dummy variables?

After we have converted our categorical variables to dummy variables for training the model.在我们将分类变量转换为虚拟变量以训练 model 之后。 We tend to find feature importance.我们倾向于发现特征的重要性。 But sklearn's model.feature_importance_ object returns feature impotance for every dummy variable, rather than the original categorical variable.但是 sklearn 的 model.feature_importance_ object 返回每个虚拟变量的特征重要性,而不是原始分类变量。 How to fix this?如何解决这个问题?

Because the dummy variables are used to train the model, you cannot find the importance of the original categorical variable.因为虚拟变量是用来训练model的,所以找不到原始分类变量的重要性。 It is mathematically impossible thing.这在数学上是不可能的事情。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM