【发布时间】:2019-01-28 19:52:10
【问题描述】:
我的问题和这个完全一样, How to get feature Importance in naive bayes?
但是当我运行代码时
neg_class_prob_sorted = NB_optimal.feature_log_prob_[0, :].argsort()
pos_class_prob_sorted = NB_optimal.feature_log_prob_[1, :].argsort()
print(np.take(count_vect.get_feature_names(), neg_class_prob_sorted[:10]))
print(np.take(count_vect.get_feature_names(), pos_class_prob_sorted[:10]))
它总是打印具有相同首字母的单词
['aafco' 'misfit' 'misfir' 'miseri' 'miser' 'misconcept' 'miscarriag'
'misc' 'mirin' 'minuscul']
['aafco' 'metrx' 'meticul' 'methood' 'metaplus' 'metaphor' 'mestemach'
'messiest' 'mesmer' 'mesa']
有没有更好的方法可以打印出正负类对应的重要特征?
【问题讨论】:
-
发布有关您的数据集、问题和完整代码的更多详细信息。是这样,没问题吗?
标签: python machine-learning scikit-learn feature-selection naivebayes