C:\Users\wwwwww>python
Python 3.6.1 |Anaconda 4.4.0 (64-bit)| (default, May 11 2017, 13:25:24) [MSC v.1900 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> from sklearn.model_selection import cross_val_score
>>> from sklearn.datasets import load_iris
>>> from sklearn.ensemble import RandomForestClassifier
>>> forest = RandomForestClassifier(n_estimators=100,random_state=1)
>>> cross_val_score(forest,load_iris().data,load_iris().target,scoring='accuracy',cv=5)
array([ 0.96666667, 0.96666667, 0.93333333, 0.96666667, 1. ])
>>> cross_val_score(forest,load_iris().data,load_iris().target,scoring='precision',cv=5)
Traceback (most recent call last):
File "", line 1, in
File "E:\dsj-software\Anaconda3-4.4.0\lib\site-packages\sklearn\model_selection\_validation.py", line 140, in cross_val_score
for train, test in cv_iter)
File "E:\dsj-software\Anaconda3-4.4.0\lib\site-packages\sklearn\externals\joblib\parallel.py", line 758, in __call__
while self.dispatch_one_batch(iterator):
File "E:\dsj-software\Anaconda3-4.4.0\lib\site-packages\sklearn\metrics\classification.py", line 1018, in precision_recall_fscore_support
"choose another average setting." % y_type)
ValueError: Target is multiclass but average='binary'. Please choose another average setting.
>>>
1个回答
ValueError: Target is multiclass but average='binary'. Please choose another average setting.
错误信息已经告诉你了,你在做多元分类,但是你用的是二元分类的scoring,所以报错了
SofaSofa数据科学社区DS面试题库 DS面经
谢谢
-
weihong
2019-12-09 09:44
相关讨论
随便看看