简体   繁体   English

AttributeError:模块“sklearn.metrics”没有属性“项目”

[英]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.

相关问题 AttributeError: 模块“sklearn.datasets”没有属性“load_titanic” - AttributeError: module 'sklearn.datasets' has no attribute 'load_titanic' AttributeError:模块“sklearn.linear_model”没有属性“linearRegression”? - AttributeError: module 'sklearn.linear_model' has no attribute 'linearRegression'? AttributeError:模块“ sklearn.mixture”没有属性“ GMM” - AttributeError: module 'sklearn.mixture' has no attribute 'GMM' kds 库给出 AttributeError: module 'kds' has no attribute 'metrics' - kds library gives AttributeError: module 'kds' has no attribute 'metrics' AttributeError:模块'keras.api._v2.keras.metrics'没有属性'auc' - AttributeError: module 'keras.api._v2.keras.metrics' has no attribute 'auc' 无法从 sklearn.metrics 导入平均绝对百分比误差 - Not able to import Mean Absolute percentage error from sklearn.metrics Python AttributeError:模块没有属性 - Python AttributeError: module has no attribute sklearn模块没有属性“ __version__” - module sklearn has no attribute ''__version__" AttributeError: 'str' object 没有属性 'items' (python) - AttributeError: 'str' object has no attribute 'items' (python) sklearn_crfsuite 中的 AttributeError 没有属性 CRF arror - AttributeError in sklearn_crfsuite has no attribute CRF arror
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM