2014-10-19 45 views
0

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

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 

回答

0

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

+0

是的,我完全错过了这部分,它解决了我的问题。谢谢! – lilyrobin 2014-10-21 00:01:37