def top_coefs(clf, label, n, vocab):
"""
Find the n features with the highest coefficients in
this classifier for this label.
See the .coef_ attribute of LogisticRegression.
Params:
clf.....LogisticRegression classifier
label...1 or 0; if 1, return the top coefficients
for the positive class; else for negative.
n.......The number of coefficients to return.
vocab...Dict from feature name to column index.
Returns:
List of (feature_name, coefficient) tuples, SORTED
in descending order of the coefficient for the
given class label.
"""
###TODO
pass
评论列表
文章目录