簡體   English   中英

如何在 Sklearn RocCurveDisplay 中設置浮點精度?

[英]How to set floating point precision in Sklearn RocCurveDisplay?

我想將 AUC 的浮點精度(如圖例所示)設置為 4 位。 我使用了 sklearn.metrics.RocCurveDisplay 中的默認sklearn.metrics.RocCurveDisplay

RocCurveDisplay.from_predictions(
   y_test, y_preds, name="CNN")

plt.show()

我有 matplotlib plot 作為,

在此處輸入圖像描述

我希望更改圖例中的 AUC 精度。

如果使用RocCurveDisplay作為打印精度是硬編碼的,似乎你不能這樣做:

        if self.roc_auc is not None and name is not None:
            line_kwargs["label"] = f"{name} (AUC = {self.roc_auc:0.2f})"
        elif self.roc_auc is not None:
            line_kwargs["label"] = f"AUC = {self.roc_auc:0.2f}"
        elif name is not None:
            line_kwargs["label"] = name

https://github.com/scikit-learn/scikit-learn/blob/7e1e6d09b/sklearn/metrics/_plot/roc_curve.py#L110

You need to plot the ROC curve in a more manual way, see https://scikit-learn.org/stable/modules/generated/sklearn.metrics.roc_curve.html and add the legend label with the precision you wish for.

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM