Skip to content
ChartslibraryUI
Get Pro

React ROC curve

How well a model separates positives from negatives at every cut-off, with AUC, or precision-recall.

Get Pro to install · $79 once<RocCurve />

A ROC curve shows how well a model separates positives from negatives at every possible score cut-off. Each point is one cut-off: how many of the real positives it catches (true positive rate) against how many negatives it wrongly flags (false positive rate). A useless model follows the diagonal; a good one bends towards the top-left corner. The area under the curve (AUC) sums it up in one number.

You pass the raw scores and true labels and the chart does the rest, including ties. Compare up to four models on one chart, each with its AUC in the legend. A cut-off (0.5 by default for probabilities) is marked with what it means in words: catches 88% of churners, flags 6% of the rest. When positives are rare, switch to the precision-recall view, which shows how many flags are right, with average precision and a chance line at the positive rate.

To show the exact mistakes at one cut-off, pair it with a confusion matrix.

When to use

  • Comparing churn, fraud or lead-scoring models
  • Choosing a score cut-off
  • Reporting AI or ML model quality

When not to use

Good practice

  • Use held-out data, not the training set.
  • Use the precision-recall view when positives are rare.
  • Mark the cut-off you actually use.

Installation

ROC curve is a Pro chart.

Installation is part of Pro

Get Pro to install it with your access key and the shadcn CLI, and use it in unlimited projects.

Unlock with Pro

Usage

Usage examples are part of Pro

Every example on this page comes with its code in Pro. The props and data shape below are public.

Unlock with Pro

Data

One row per scored item with a score key and a true-label key; optional model key to compare models.

[{ model: "New model", score: 0.83, churned: true }, ...]

Missing values are null. Invalid values make the chart say what’s wrong instead of drawing a misleading picture. How charts handle bad data

Props

Every chart also accepts the shared frame props: title, subtitle, source, height, mode, toolbar. Common API

export interface RocCurveProps extends FrameProps {
  /** Raw predictions, one row per scored item. See the Data section for the shape. */
  data: Row[];
  /** Key of the model's score (higher = more likely positive), e.g. a probability. */
  score: string;
  /** Key of the true label. */
  actual: string;
  /** The value of `actual` that counts as positive. Default: true, 1, "1", "yes", "true" or "positive". */
  positive?: string | number | boolean;
  /** Optional key of the model name, to compare up to 4 models on one chart. */
  model?: string;
  /** "roc" (true positive rate vs false positive rate, default) or "pr" (precision vs recall, better when positives are rare). */
  curve?: "roc" | "pr";
  /** Score cut-off to mark on each curve. Default 0.5 when every score is between 0 and 1. */
  threshold?: number;
}

Confusion matrix

Actual vs predicted classes for a classifier, with recall per row, precision per column and accuracy.

Line chart

Trends over time for one to four series, with gaps for missing data and marked forecasts.

Scatter chart

The relationship between two measures, with groups, bubbles, quadrants and a trend line.

Sign in to ChartslibraryUI

New here? The same step creates your account.

Continue with Google
or

No password needed. Bought Pro? Use the email you paid with and your license is there. By signing in you agree to the Terms and Privacy policy.