Python CountVectorizer忽略大写

Python CountVectorizer忽略大写,python,pandas,numpy,scikit-learn,Python,Pandas,Numpy,Scikit Learn,CountVectorizer忽略大写单词的原因是什么 cv = CountVectorizer(stop_words=None,analyzer='word',token_pattern='.*',max_features=None) text = ['this','is','a','Test','!'] fcv = cv.fit_transform(list) fcv = [cv.vocabulary_.get(t) for t in text] print fcv 返回 [5, 3, 2

CountVectorizer忽略大写单词的原因是什么

cv = CountVectorizer(stop_words=None,analyzer='word',token_pattern='.*',max_features=None)
text = ['this','is','a','Test','!']
fcv = cv.fit_transform(list)
fcv = [cv.vocabulary_.get(t) for t in text]
print fcv
返回

[5, 3, 2, None, 1]
这是因为在CountVectorizer中,默认情况下lowercase设置为True,add lowercase=False


对尽管如此,您可能只是想要[cv.vocability\uuu.gett.lower for t in text],而不是为测试和测试提供不同的特性……哎呀,我没有注意到有一个参数。谢谢大家!@Sindico是的,但您可能不想使用该参数!有一个很好的理由可以解释为什么它默认为True。
cv = CountVectorizer(stop_words=None, analyzer='word', token_pattern='.*',
        max_features=None, lowercase=False)