ValueError Traceback (most recent call last) <ipython-input-43-7bbaad1a6872> in <module>() ----> 1 metrics.accuracy_score(y_true,y_pred) D:\Downloads\ancanda\lib\site-packages\sklearn\metrics\classification.py in accuracy_score(y_true, y_pred, normalize, sample_weight) 174 175 # Compute accuracy for each possible representation --> 176 y_type, y_true, y_pred = _check_targets(y_true, y_pred) 177 if y_type.startswith('multilabel'): 178 differing_labels = count_nonzero(y_true - y_pred, axis=1) D:\Downloads\ancanda\lib\site-packages\sklearn\metrics\classification.py in _check_targets(y_true, y_pred) 86 # No metrics support "multiclass-multioutput" format 87 if (y_type not in ["binary", "multiclass", "multilabel-indicator"]): ---> 88 raise ValueError("{0} is not supported".format(y_type)) 89 90 if y_type in ["binary", "multiclass"]: ValueError: unknown is not supported
时间: 2024-01-09 07:03:46 浏览: 438
2-3-python编程基础知识-基本数据类型.ppt
这个错误通常发生在使用 sklearn.metrics.accuracy_score 函数时,y_true 或 y_pred 参数的格式不正确。你可以检查一下 y_true 和 y_pred 的格式是否正确,比如是否是 numpy 数组,是否是一维数组等等。另外,如果你的数据集是多分类问题,可以考虑使用 sklearn.metrics.confusion_matrix 函数来计算准确率。
阅读全文