简体   繁体   中英

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

for title, metric in metrics.items():

AttributeError: module 'sklearn.metrics' has no attribute 'items'

I have tried with versions from scikit-learn=0.20.0 to 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() .

.items() is used for dictionaries in order to get the values pertaining to different keys in that dictionary.

Also, you have defined y_pred after it has been referenced, so that will cause an error as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM