以下代码
from sklearn import metrics
import numpy as np
y_true = np.array([[0.2,0.8,0],[0.9,0.05,0.05]])
y_predict = np.array([[0.5,0.5,0.0],[0.5,0.4,0.1]])
metrics.log_loss(y_true, y_predict)
产生以下错误:
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<ipython-input-32-24beeb19448b> in <module>()
----> 1 metrics.log_loss(y_true, y_predict)
~\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\sklearn\metrics\classification.py in log_loss(y_true, y_pred, eps, normalize, sample_weight, labels)
1646 lb.fit(labels)
1647 else:
-> 1648 lb.fit(y_true)
1649
1650 if len(lb.classes_) == 1:
~\AppData\Local\conda\conda\envs\tensorflow\lib\site-packages\sklearn\preprocessing\label.py in fit(self, y)
276 self.y_type_ = type_of_target(y)
277 if 'multioutput' in self.y_type_:
--> 278 raise ValueError("Multioutput target data is not supported with "
279 "label binarization")
280 if _num_samples(y) == 0:
ValueError: Multioutput target data is not supported with label binarization
我很好奇为什么。我正在尝试重新阅读日志丢失的定义,但找不到任何会使计算不正确的东西。