【发布时间】:2021-02-26 00:44:14
【问题描述】:
有时在使用 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))
【问题讨论】:
标签: python-3.x scikit-learn metrics