> ## Documentation Index
> Fetch the complete documentation index at: https://wb-21fd5541-docs-2516.mintlify.site/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 ? "ソースを表示" : <>
    <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 のソース
      </>}
  </a>;

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

## <Badge color="blue" size="lg" shape="rounded">関数</Badge> wandb.plot.pr\_curve()

Precision-Recall (PR) 曲線を作成します。

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

```python theme={null}
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
```

<div id="args">
  ## 引数
</div>

<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">
  プロットのタイトルです。デフォルトは「Precision-Recall Curve」です。
</ResponseField>

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

<div id="returns">
  ## 戻り値
</div>

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

<div id="raises">
  ## 例外
</div>

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

<div id="examples">
  ## 例
</div>

```python theme={null}
import wandb

# スパム検出の例（二値分類）
y_true = [0, 1, 1, 0, 1]  # 0 = スパムでない, 1 = スパム
y_probas = [
    [0.9, 0.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})
```
