TypeError Traceback (most recent call last)
Cell In[58], line 161
159 plt.xlabel("FPR")
160 plt.ylabel("TPR")
--> 161 plt.annotate(xy= (.4,.2),xytext= (.5,.2),s = 'ROC curve (area = % 0.2f)' % auc_test)
TypeError: annotate() missing 1 required positional argument: 'text'
后面百度查了一下发现,matplotlib3.3及以后,将这个函数中的参数s改为了test。
解决办法:
将参数改为test=test。
还有一种办法将这个matplotlib包降到3.3之前的版本。不过第一种解决办法比较简单,在这里建议使用第一种方法。
本文介绍了在更新到matplotlib3.3版本后,由于函数`annotate()`的`s`参数更改为`test`,导致的TypeError问题。提供了两种解决方案:一是直接更新代码中的参数,另一种是降级matplotlib包版本。推荐使用前者以适应新版本。

1184

被折叠的 条评论
为什么被折叠?



