You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何解决AttributeError: module 'scikitplot' has no attribute 'plot_precision_recall_curve'错误

解决AttributeError: module 'scikitplot' has no attribute 'plot_precision_recall_curve'的方法

1. 修正导入路径

scikitplot的plot_precision_recall_curve函数属于metrics子模块,并非直接挂载在根模块下。需要调整导入语句:

from scikitplot.metrics import plot_precision_recall_curve

之后直接调用plot_precision_recall_curve()即可,无需添加scikitplot.前缀。

2. 升级scikitplot版本

如果你的scikitplot版本过旧,可能不存在该函数。执行以下命令升级至最新版:

pip install --upgrade scikitplot

3. 替代方案:使用scikit-learn原生函数

若上述方法仍无法解决问题,可直接使用scikit-learn自带的同功能函数,导入和用法示例如下:

from sklearn.metrics import plot_precision_recall_curve
import matplotlib.pyplot as plt

# 绘制精确率-召回率曲线
disp = plot_precision_recall_curve(rfcmodel, X_test, y_test)
disp.figure_.suptitle("Precision-Recall Curve")
plt.show()

内容的提问来源于stack exchange,提问作者Nikita Narwani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.07.28 21:12:39