Sklearn ValueError: empty vocabulary; perhaps the documents only contain stop words

中文语料:

拆成单字的列表

荣 耀 内 幕 我 不 多
华 为 用 户 如 果 发 现 续 航 不 足 一 天 的 请 凭 余 总 微 博 进 行 合 理 维 权
便 宜 了 5 0 0 多 g

使用

CountVectorizer()

报错:

Sklearn ValueError: empty vocabulary; perhaps the documents only contain stop words

 

问题:

def __init__(self, input='content', encoding='utf-8',
             decode_error='strict', strip_accents=None,
             lowercase=True, preprocessor=None, tokenizer=None,
             stop_words=None, token_pattern=r"(?u)\b\w\w+\b",
             ngram_range=(1, 1), analyzer='word',
             max_df=1.0, min_df=1, max_features=None,
             vocabulary=None, binary=False, dtype=np.int64):

解决方案

CountVectorizer()默认analysis =“word”,改成CountVectorizer(analysis =“char”,lowercase=False)就好了

 

 

  • 5
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 9
    评论
评论 9
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值