sklearn.feature_extraction.text.TfidfVectorizer,文本TFIDF向量化类使用说明

class sklearn.feature_extraction.text.TfidfVectorizer(input=’content’, encoding=’utf-8’, decode_error=’strict’, strip_accents=None, lowercase=True, preprocessor=None, tokenizer=None, analyzer=’word’, stop_words=None, token_pattern=’(?u)\b\w\w+\b’, ngram_range=(1, 1), max_df=1.0, min_df=1, max_features=None, vocabulary=None, binary=False, dtype=<class ‘numpy.int64’>, norm=’l2’, use_idf=True, smooth_idf=True, sublinear_tf=False)

调用方法:from sklearn.feature_extraction.text import  TfidfVectorizer

将原始文本集转换为TFIDF向量矩阵,相当于先进行文本向量化再进行TDIDF化。

参数说明:

1, input : string {‘filename’, ‘file’, ‘content’}

可以是需要处理的文件名称列表(filename),也可以是具体的一个文件(file),也可以是字符串(content)

2,encoding : string, ‘utf-8’ by default.

编码方式,说明输入文件的编码方式,默认为utf-8

3,decode_error : {‘strict’, ‘ignore’, ‘replace’}

4,strip_accents : {‘ascii’, ‘unicode’, None}

5,analyzer : string, {‘word’, ‘char’} or callable

6,preprocessor : callable or None (default)

7,tokenizer : callable or None (default)

8,ngram_range : tuple (min_n, max_n)

9,stop_words : string {‘english’}, list, or None (default)

10,lowercase : boolean, default True

11,token_pattern : string

12,max_df : float in range [0.0, 1.0] or int, default=1.0

词频上限,当输入整数值时不考虑出现次数多于给定次数的词,当输入0到1的浮点数值时看作词汇在文档中所占比例上限,如果前面给定了词典,这一参数将被忽略。

13,min_df : float in range [0.0, 1.0] or int, default=1

词频下限,当输入整数值时不考虑出现次数少于给定次数的词,当输入0到1的浮点数值时看作词汇在文档中所占比例下限,如果前面给定了词典,这一参数将被忽略。

14,max_features : int or None, default=None

15,vocabulary : Mapping or iterable, optional

16,binary : boolean, default=False

17,dtype : type, optional

18,norm : ‘l1’, ‘l2’ or None, optional

19,use_idf : boolean, default=True

20,smooth_idf : boolean, default=True

21,sublinear_tf : boolean, default=False

方法使用说明:

1,build_analyzer()

2,build_preprocessor()

3,build_tokenizer()

4,decode(doc)

5,fit(raw_documents[, y])

fit_transform(raw_documents, y=None)

6,fit_transform(raw_documents[, y])

7,get_feature_names()

8,get_params([deep])

9,get_stop_words()

10,inverse_transform(X)

11,set_params(**params)

12,transform(raw_documents[, copy])






  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值