我想用32个预测的蒙版图像和32个真实的蒙版图像做f1评分。我的数据有以下特点:
predicted.shape [32,512,512]
true.shape [32,512,512]
type_of_target(predicted) Unknown
type_of_target(true) Unknown
type_of_target(predicted[0]) Continuous-multioutput
type_of_target(true[0]) Continuous-multioutput当我运行这一行f1_score(true,predicted,average='macro')时,我得到这个错误:
f1_score(true, predicted, average='macro')
Traceback (most recent call last):
File "<ipython-input-75-7198c91642b6>", line 1, in <module>
f1_score(true, predicted, average='macro')
File "C:\Anaconda3\lib\site-packages\sklearn\metrics\_classification.py", line 1099, in f1_score
zero_division=zero_division)
File "C:\Anaconda3\lib\site-packages\sklearn\metrics\_classification.py", line 1226, in fbeta_score
zero_division=zero_division)
File "C:\Anaconda3\lib\site-packages\sklearn\metrics\_classification.py", line 1484, in precision_recall_fscore_support
pos_label)
File "C:\Anaconda3\lib\site-packages\sklearn\metrics\_classification.py", line 1301, in _check_set_wise_labels
y_type, y_true, y_pred = _check_targets(y_true, y_pred)
File "C:\Anaconda3\lib\site-packages\sklearn\metrics\_classification.py", line 97, in _check_targets
raise ValueError("{0} is not supported".format(y_type))
ValueError: unknown is not supported发布于 2020-04-26 10:37:17
F1-Score是精确度和召回率的调和平均值。当预测值是分类的而不是连续的输出时,计算精度和召回率。您需要将预测转换为分类预测(通过向上舍入或向下舍入),然后展平数组,因为f1_score函数只接受一维数组作为输入参数。
发布于 2020-04-26 08:03:32
我认为F1输入应该是一维数组(标签)。请确保这一点。
https://stackoverflow.com/questions/61433955
复制相似问题