本文整理汇总了Python中sklearn.feature_extraction.text.Vectorizer.get_feature_names方法的典型用法代码示例。如果您正苦于以下问题:Python Vectorizer.get_feature_names方法的具体用法?Python Vectorizer.get_feature_names怎么用?Python Vectorizer.get_feature_names使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sklearn.feature_extraction.text.Vectorizer
的用法示例。
在下文中一共展示了Vectorizer.get_feature_names方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: time
# 需要导入模块: from sklearn.feature_extraction.text import Vectorizer [as 别名]
# 或者: from sklearn.feature_extraction.text.Vectorizer import get_feature_names [as 别名]
opts.select_chi2)
t0 = time()
ch2 = SelectKBest(chi2, k=opts.select_chi2)
X_train = ch2.fit_transform(X_train, y_train)
X_test = ch2.transform(X_test)
print "done in %fs" % (time() - t0)
print
def trim(s):
"""Trim string to fit on terminal (assuming 80-column display)"""
return s if len(s) <= 80 else s[:77] + "..."
# mapping from integer feature name to original token string
feature_names = vectorizer.get_feature_names()
###############################################################################
# Benchmark classifiers
def benchmark(clf):
print 80 * '_'
print "Training: "
print clf
t0 = time()
clf.fit(X_train, y_train)
train_time = time() - t0
print "train time: %0.3fs" % train_time
t0 = time()
pred = clf.predict(X_test)