在scikit-learn中没有idf_的输出

时间:2014-10-19 23:42:25

标签: python scikit-learn

我在scikit-learn中使用TfidfVectorizo​​r功能。我试图使用" use_idf = True"来包含tf-idf元素。在文档中,它说在此之后,result.idf_应该返回我的idf权重的数组和形状,但是我得到了#34;无"。以下是我的输入和输出。 (我最终试图判断min_df和max_df如何影响我的结果,所以它们现在只是随机值)。

tester =TfidfVectorizer(docs_train, min_df=.2, max_df=.8, use_idf=True)

print tester

TfidfVectorizer(analyzer=u'word', binary=False, charset=None,
        charset_error=None, decode_error=u'strict',
        dtype=<type 'numpy.int64'>, encoding=u'utf-8',
        input=["today , war became a reality to me after seeing a screening of saving     priivate ryan . \nsteve spielberg goes beyond reality with his latest production . \nthe audience is tossed about the theatre witnessing the horror of war . \nplease keep the kids home as the r rating is for reality . \nto...esting motif out of the ubiquitous palmetto bugs-but nothing can freshen up this stale script . \n'],
    lowercase=True, max_df=0.8, max_features=None, min_df=0.2,
    ngram_range=(1, 1), norm=u'l2', preprocessor=None, smooth_idf=True,
    stop_words=None, strip_accents=None, sublinear_tf=False,
    token_pattern=u'(?u)\\b\\w\\w+\\b', tokenizer=None, use_idf=True,
    vocabulary=None)

print tester.idf_

None

1 个答案:

答案 0 :(得分:0)

您还没有为矢量图提供任何数据。您应该使用fitfit_transform

执行此操作