scikit-learn:CountVectorizer提取tf都做了什么

本文详细探讨了scikit-learn库中的CountVectorizer如何从文本中提取特征,尤其是它如何计算词频(Term Frequency, TF),这是文本挖掘和自然语言处理中的重要步骤。CountVectorizer通过对文本进行分词、建立词汇表并转换为词频矩阵来实现这一过程。" 110526019,10296476,Seaborn lmplot教程:Python回归图绘制,"['Python可视化', '统计图形', '数据科学', 'Seaborn库', '回归分析']

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://scikit-learn.org/stable/modules/generated/sklearn.feature_extraction.text.CountVectorizer.html#sklearn.feature_extraction.text.CountVectorizer


class  sklearn.feature_extraction.text. CountVectorizer ( input=u'content'encoding=u'utf-8'decode_error=u'strict', strip_accents=Nonelowercase=Truepreprocessor=Nonetokenizer=Nonestop_words=None, token_pattern=u'(?u)\b\w\w+\b'ngram_range=(11)analyzer=u'word'max_df=1.0min_df=1, max_features=Nonevocabulary=Nonebinary=Falsedtype=<type 'numpy.int64'> ) [source]

作用:Convert a collection of text documents to a matrix of token counts(计算词汇的数量,即tf);结果由 scipy.sparse.coo_matrix进行稀疏表示。

看下参数就知道CountVectorizer在提取tf时都做了什么:

strip_accents : {‘ascii’, ‘unicode’, None}:是否除去“音调”,不知道什么是“音调”?看:http://textmechanic.com/?reqp=1&reqr=nzcdYz9hqaSbYaOvrt==


lowercase : boolean, True by default:计算tf前,先将所有字符转化为小写。这个参数一般为True。


preprocessor : callable or None (default):复写the preprocessing (string transformation) stage,但保留tokenizing and n-grams generation steps.这个参数可以自己写。


评论 8
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值