> ## Documentation Index
> Fetch the complete documentation index at: https://docs.coreweave.com/llms.txt
> Use this file to discover all available pages before exploring further.

# pr_curve()

export const GitHubLink = ({url, compact = false}) => <a href={url} target="_blank" rel="noopener noreferrer" className={compact ? "source-link" : "github-source-link"}>
    {compact ? "View source" : <>
    <svg width="20" height="20" viewBox="0 0 24 24" fill="currentColor" xmlns="http://www.w3.org/2000/svg">
      <path d="M12 0C5.37 0 0 5.37 0 12c0 5.31 3.435 9.795 8.205 11.385.6.105.825-.255.825-.57 0-.285-.015-1.23-.015-2.235-3.015.555-3.795-.735-4.035-1.41-.135-.345-.72-1.41-1.23-1.695-.42-.225-1.02-.78-.015-.795.945-.015 1.62.87 1.845 1.23 1.08 1.815 2.805 1.305 3.495.99.105-.78.42-1.305.765-1.605-2.67-.3-5.46-1.335-5.46-5.925 0-1.305.465-2.385 1.23-3.225-.12-.3-.54-1.53.12-3.18 0 0 1.005-.315 3.3 1.23.96-.27 1.98-.405 3-.405s2.04.135 3 .405c2.295-1.56 3.3-1.23 3.3-1.23.66 1.65.24 2.88.12 3.18.765.84 1.23 1.905 1.23 3.225 0 4.605-2.805 5.625-5.475 5.925.435.375.81 1.095.81 2.22 0 1.605-.015 2.895-.015 3.3 0 .315.225.69.825.57A12.02 12.02 0 0024 12c0-6.63-5.37-12-12-12z" />
    </svg>
    GitHub source
      </>}
  </a>;

<GitHubLink compact url="https://github.com/wandb/wandb/blob/main/wandb/plot/pr_curve.py#L19" />

<h2 id="function-wandbplotpr_curve">
  <Badge color="blue" size="lg" shape="rounded">function</Badge> wandb.plot.pr\_curve()
</h2>

適合率-再現率 (PR) 曲線を作成します。

適合率-再現率曲線は、不均衡なデータセットで分類器を評価する際に特に有用です。
PR 曲線の下の面積が大きい場合、適合率が高く (偽陽性率が低い)、
再現率も高い (偽陰性率が低い) ことを示します。この曲線から、さまざまな
しきい値における偽陽性と偽陰性のバランスを把握できるため、
モデルのパフォーマンスの評価に役立ちます。

```python theme={"system"}
y_true: 'Iterable[T] | None' = None,
y_probas: 'Iterable[numbers.Number] | None' = None,
labels: 'list[str] | None' = None,
classes_to_plot: 'list[T] | None' = None,
interp_size: 'int' = 21,
title: 'str' = 'Precision-Recall Curve',
split_table: 'bool' = False
```

<h2 id="args">
  引数
</h2>

<ResponseField name="y_true" type="Iterable[T] | None">
  正解の二値ラベル。形状は (`num_samples`,) である必要があります。
</ResponseField>

<ResponseField name="y_probas" type="Iterable[numbers.Number] | None">
  各クラスの予測スコアまたは確率。確率の推定値、信頼度スコア、またはしきい値処理前の決定値を指定できます。形状は (`num_samples`, `num_classes`) である必要があります。
</ResponseField>

<ResponseField name="labels" type="list[str] | None">
  `y_true` の数値を置き換えるクラス名のリスト (オプション)。プロットが解釈しやすくなります。たとえば、`labels = ['dog', 'cat', 'owl']` を指定すると、プロット内で 0 が 'dog'、1 が 'cat'、2 が 'owl' に置き換えられます。指定しない場合は、`y_true` の数値がそのまま使用されます。
</ResponseField>

<ResponseField name="classes_to_plot" type="list[T] | None">
  プロットに含める、y\_true の一意なクラス値のリスト (オプション)。指定しない場合は、y\_true のすべての一意なクラスがプロットされます。
</ResponseField>

<ResponseField name="interp_size" type="int">
  再現率 値の補間に使用するポイントの数。再現率 値は範囲 \[0, 1] に均等に分布する `interp_size` 個のポイントに固定され、適合率 はそれに合わせて補間されます。
</ResponseField>

<ResponseField name="title" type="str">
  プロットのタイトル。デフォルトは "適合率-再現率 Curve" です。
</ResponseField>

<ResponseField name="split_table" type="bool">
  W\&B UI で表を別のセクションに分けて表示するかどうか。`True` の場合、表は "Custom Chart Tables" という名前のセクションに表示されます。デフォルトは `False` です。
</ResponseField>

<h2 id="returns">
  戻り値
</h2>

`CustomChart`: W\&B にログできるカスタム チャート オブジェクトです。チャートをログするには、このオブジェクトを `wandb.log()` に渡します。

<h2 id="raises">
  送出される例外
</h2>

* `wandb.Error`: NumPy、pandas、または scikit-learn がインストールされていない場合。

<h2 id="examples">
  サンプル
</h2>

```python theme={"system"}
import wandb

# スパム検出（二値分類）の例
y_true = [0, 1, 1, 0, 1]  # 0 = スパムではない、1 = スパム
y_probas = [
    [0.9, 0.1],  # 1 つ目のサンプル（スパムではない）の予測確率
    [0.2, 0.8],  # 2 つ目のサンプル（スパム）。以降も同様
    [0.1, 0.9],
    [0.8, 0.2],
    [0.3, 0.7],
]

labels = ["not spam", "spam"]  # 読みやすくするためのクラス名（オプション）

with wandb.init(project="spam-detection") as run:
    pr_curve = wandb.plot.pr_curve(
        y_true=y_true,
        y_probas=y_probas,
        labels=labels,
        title="Precision-Recall Curve for Spam Detection",
    )
    run.log({"pr-curve": pr_curve})
```


## Related topics

- [カスタム チャートの概要](/ja/products/wandb/ref/python/custom-charts.md)
