[英]AttributeError: module 'sklearn.metrics' has no attribute 'items'
Here is my code..这是我的代码..
import imp
from sklearn.metrics import classification_report
from sklearn import metrics
from sklearn.metrics import accuracy_score
for title, metric in metrics.items():
print(title, metric(labels_categorical_dev.argmax(axis=1), y_pred.argmax(axis=1)))
print(classification_report(labels_categorical_dev.argmax(axis=1), y_pred.argmax(axis=1)))
y_pred = model.predict([message_first_message_test, message_second_message_test, message_third_message_test])
Iam getting below error..我正在低于错误..
Traceback (most recent call last):回溯(最近一次通话最后):
File "getopt.py", line 6, in文件“getopt.py”,第 6 行,在
for title, metric in metrics.items():
AttributeError: module 'sklearn.metrics' has no attribute 'items' AttributeError:模块“sklearn.metrics”没有属性“项目”
I have tried with versions from scikit-learn=0.20.0 to scikit-learn=0.24.2我尝试过从 scikit-learn=0.20.0 到 scikit-learn=0.24.2 的版本
But still getting this error.但仍然收到此错误。 Please give me a solution for this.
请给我一个解决方案。
Can you share more details about what is the purpose of your code?您能否分享有关代码用途的更多详细信息? As you can see here , there isn't any attribute of
sklearn.metrics
named items()
.正如您在此处看到的,
sklearn.metrics
没有任何名为items()
的属性。
.items()
is used for dictionaries in order to get the values pertaining to different keys in that dictionary. .items()
用于字典,以获取与该字典中不同键有关的值。
Also, you have defined y_pred
after it has been referenced, so that will cause an error as well.此外,您在
y_pred
被引用后定义了它,因此也会导致错误。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.