python分类器哪几种_python – scikit-learn确定所选类别的分类器的分类/分数

我正在做一些多类文本分类,它可以很好地满足我的需求:

classifier = Pipeline([

('vect', CountVectorizer(tokenizer=my_tokenizer, stop_words=stopWords, ngram_range=(1, 2), min_df=2)),

('tfidf', TfidfTransformer(norm='l2', use_idf=True, smooth_idf=True, sublinear_tf=False)),

('clf', MultinomialNB(alpha=0.01, fit_prior=True))])

categories = [list of my possible categories]

# Learning

news = [list of news already categorized]

news_cat = [the category of the corresponding news]

news_target_cat = numpy.searchsorted(categories, news_cat)

classifier = classifier.fit(news, news_target_cat)

# Categorizing

news = [list of news not yet categorized]

predicted = classifier.predict(news)

for i, pred_cat in enumerate(predicted):

print(news[i])

print(categories[pred_cat])

现在,我想要预测的类别是预测变量的“确定性”(例如:0.0 – >“我已经掷骰子选择一个类别”最多1.0 – >;“没有什么能改变我的关注那个新闻的类别“).我应该如何获得该类别的确定性值/预测值得分?

解决方法:

如果您需要类别概率之类的东西,则必须使用分类器的predict_proba()方法.

标签:python,machine-learning,classification,scikit-learn

来源: https://codeday.me/bug/20190628/1312466.html

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值