小编Int*_*777的帖子

面对ValueError:目标是多类的,但average ='binary'

我是python和机器学习的新手。根据我的要求,我正在尝试对数据集使用朴素贝叶斯算法。

我能够找出准确度,但尝试找出准确度并回想一下。但是,它引发以下错误:

   "choose another average setting." % y_type)
ValueError: Target is multiclass but average='binary'. Please choose another average setting.
Run Code Online (Sandbox Code Playgroud)

谁能建议我如何进行。我曾尝试在平均值和召回率分数中使用average ='micro'。它的工作原理没有任何错误,但在准确性,准确性和召回率上却给出了相同的分数。

我的数据集:

train_data.csv:

review,label
Colors & clarity is superb,positive
Sadly the picture is not nearly as clear or bright as my 40 inch Samsung,negative
Run Code Online (Sandbox Code Playgroud)

test_data.csv:

review,label
The picture is clear and beautiful,positive
Picture is not clear,negative
Run Code Online (Sandbox Code Playgroud)

我的代码:

from sklearn.preprocessing import MultiLabelBinarizer
from sklearn.model_selection import train_test_split
from sklearn.naive_bayes import BernoulliNB
from sklearn.metrics import confusion_matrix
from sklearn.feature_extraction.text import CountVectorizer
from sklearn.naive_bayes import …
Run Code Online (Sandbox Code Playgroud)

python scikit-learn

5
推荐指数
2
解决办法
9416
查看次数

标签 统计

python ×1

scikit-learn ×1