在larsmans代码的帮助下,我想到了以下二进制情况的代码:
def show_most_informative_features(vectorizer, clf, n=20):
feature_names = vectorizer.get_feature_names()
coefs_with_fns = sorted(zip(clf.coef_[0], feature_names))
top = zip(coefs_with_fns[:n], coefs_with_fns[:-(n + 1):-1])
for (coef_1, fn_1), (coef_2, fn_2) in top:
print "\t%.4f\t%-15s\t\t%.4f\t%-15s" % (coef_1, fn_1, coef_2, fn_2)
0
诸如liblinear和nltk之类的机器学习包中的分类器提供了
show_most_informative_features()
方法,该方法对于调试功能确实很有帮助:我的问题是,是否对scikit-learn中的分类器实施了类似的操作。我搜索了文档,但找不到类似的东西。
如果尚无此类功能,是否有人知道如何解决这些值的解决方法?
非常感谢!