有时在使用sklearn.metrics.classification_report时,会出现以下错误。
有时,根据数据类型,我们还会出现以下错误:
TypeError: object of type 'int' has no len()
有时,根据数据类型,我们还会出现以下错误:
TypeError: object of type 'numpy.int64' has no len()
可能导致出现此错误的示例代码
t=pd.Series([1,2,3,4])
p=np.asarray([1,2,3,4])
target_names=[1,2,3,4]
print(classification_report(t, p, target_names=target_names))
HuggingFace
中使用metric.load('bertscore')
的解决方案相同。 - Alaa M.