从分类器中检索训练功能名称列表 [英] Retrieve list of training features names from classifier
问题描述
用fit
方法训练分类器后,是否有一种方法可以检索用于训练分类器的特征名称列表?我希望在申请看不见的数据之前获得此信息.
用于训练的数据是大熊猫DataFrame
,在我的情况下,分类器是RandomForestClassifier
.
Is there a way to retrieve the list of feature names used for training of a classifier, once it has been trained with the fit
method? I would like to get this information before applying to unseen data.
The data used for training is a pandas DataFrame
and in my case, the classifier is a RandomForestClassifier
.
推荐答案
根据文档和以前的经验,无法获取至少在一项拆分中考虑的功能的列表.
Based on the documentation and previous experience, there is no way to get a list of the features considered at least at one of the splitting.
您是否担心不想将所有功能都用于预测,而只是想将其实际用于训练?在这种情况下,我建议在拟合后列出feature_importances_
,并消除似乎不相关的功能.然后训练仅具有相关特征的新模型,并将这些特征也用于预测.
Is your concern that you do not want to use all your features for prediction, just the ones actually used for training? In this case I suggest to list the feature_importances_
after fitting and eliminate the features that does not seem relevant. Then train a new model with only the relevant features and use those features for prediction as well.
这篇关于从分类器中检索训练功能名称列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!