【发布时间】:2020-07-21 07:35:01
【问题描述】:
我正在研究文本分类问题并使用 TFIDF 矢量化器生成文本特征。
这里是代码
tfidf_vectorizer = TfidfVectorizer(use_idf=True,
# stop_words=English_Stopwords,
ngram_range=(1,3),
min_df=0.10, # ignore terms that have a document frequency strictly lower than the given threshold
max_df=0.80,
smooth_idf=True)
fitted_vect = tfidf_vectorizer.fit(df_sample[TEXT_FEAT])
transformed_X_train = tfidf_vectorizer.transform(X_train)
transformed_X_val = tfidf_vectorizer.transform(X_val)
我查了词汇表,它只包含 162 个单词,而停用词列表非常庞大。这里有什么问题。
print(len(fitted_vect.vocabulary_))
# 162
print(len(fitted_vect.stop_words_))
# 16969712
【问题讨论】:
标签: python-3.x nlp tfidfvectorizer