Menu

Model Evaluation and Diagnostic Accuracy

ROC Curve Generator with AUC, Sensitivity, and Specificity

A ROC curve shows how a classifier or diagnostic test trades sensitivity against false positives across every decision threshold. Plotivy turns prediction scores and true labels into a publication-ready Python figure with the area under the curve, the chance diagonal, and clearly labeled axes.

When a ROC Curve Is the Right Choice

Use a ROC curve when you need to summarize how well a continuous score separates two classes without committing to a single cutoff. It is the standard format for reporting machine-learning classifiers and clinical diagnostic tests because the area under the curve gives one threshold-independent number for overall discrimination.

Model evaluation

Compare classifiers on a single AUC number that does not depend on a cutoff.

Diagnostic tests

Report sensitivity and specificity trade-offs for a biomarker or assay.

Threshold selection

Read off the operating point that balances false positives and false negatives.

Honest baseline

The chance diagonal makes it obvious when a model is no better than guessing.

What Plotivy Adds to the Workflow

AUC computed in code

The area under the curve is calculated from your scores with the trapezoidal rule, not estimated by eye.

Readable operating points

Sensitivity and specificity axes are labeled so reviewers can locate the threshold you chose.

Fair comparison baseline

The chance diagonal and a shaded area keep weak and strong models visually distinct.

Reproducible Python output

Every figure is editable code, so co-authors can trace the exact thresholds and scoring.

Live Code Lab: ROC Curve

This example simulates model scores for 200 cases, sweeps every score as a decision threshold, and plots the true positive rate against the false positive rate with the area under the curve in the legend. Swap in your own scores and labels to evaluate a real model.

Chart gallery

Related Chart Types

Other chart templates for model evaluation and diagnostic reporting

Browse all chart types →
ROC curve showing sensitivity on y-axis versus 1-specificity on x-axis with AUC annotation and diagonal no-skill reference line
Statistical•matplotlib, numpy
From the chart gallery•Evaluating and comparing diagnostic biomarkers for disease detection in case-control studies

ROC Curve

Plot true positive rate against false positive rate across all decision thresholds with AUC annotation for model and diagnostic test evaluation.

Sample code / prompt

import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)
def generate_roc(auc_target, n_points=100):
    fpr = np.sort(np.concatenate([[0], np.random.beta(1, auc_target * 5, n_points - 2), [1]]))
    tpr = np.sort(np.concatenate([[0], np.random.beta(auc_target * 5, 1, n_points - 2), [1]]))
    return fpr, tpr

fig, ax = plt.subplots(figsize=(10, 10))
Precision-recall curve showing precision on y-axis versus recall on x-axis with average precision annotation and F1 iso-curves
Statistical•matplotlib, numpy
From the chart gallery•Evaluating rare disease detection models where positive class prevalence is below 5%

Precision-Recall Curve

Plot precision against recall across thresholds to evaluate classifier performance on imbalanced datasets with average precision annotation.

Sample code / prompt

import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)
fig, ax = plt.subplots(figsize=(10, 10))
models = [('Random Forest', 0.88, '#3b82f6'), ('Gradient Boost', 0.92, '#ef4444'),
          ('SVM', 0.78, '#10b981'), ('Baseline', 0.65, '#94a3b8')]
for name, ap, color in models:
    recall = np.sort(np.concatenate([[0], np.random.uniform(0, 1, 50), [1]]))
    precision = ap + (1 - recall) * (1 - ap) * np.random.uniform(0.5, 1.5, len(recall))
Confusion matrix heatmap with color-coded cells showing true vs predicted class counts
Statistical•matplotlib, numpy
From the chart gallery•Evaluating multi-class image classification model performance

Confusion Matrix

A heatmap showing true vs. predicted class labels to evaluate classification model accuracy.

Sample code / prompt

import matplotlib.pyplot as plt
import numpy as np
import seaborn as sns

np.random.seed(42)
classes = ['Cat', 'Dog', 'Bird', 'Fish', 'Horse']
n = len(classes)
cm = np.random.randint(0, 20, (n, n))
np.fill_diagonal(cm, np.random.randint(60, 95, n))
cm_normalized = cm.astype('float') / cm.sum(axis=1)[:, np.newaxis]
Calibration plot showing predicted probability on x-axis and observed fraction of positives on y-axis with ideal diagonal reference line
Statistical•matplotlib, numpy
From the chart gallery•Validating clinical prediction models for mortality, readmission, or disease probability

Calibration Plot

Plot predicted probabilities against observed event frequencies to assess calibration of diagnostic or prognostic models.

Sample code / prompt

import matplotlib.pyplot as plt
import numpy as np

np.random.seed(42)
n_bins = 10
predicted_probs = np.linspace(0.05, 0.95, n_bins)
observed_probs = predicted_probs + np.random.normal(0, 0.05, n_bins)
observed_probs = np.clip(observed_probs, 0, 1)
counts = np.random.randint(50, 200, n_bins)
Multi-line graph showing temperature trends for 3 cities over a year
Time Series•matplotlib, seaborn
From the chart gallery•Stock price tracking over time

Line Graph

Displays data points connected by straight line segments to show trends over time.

Sample code / prompt

import matplotlib.pyplot as plt
import numpy as np

# Generate temperature data for 3 major US cities over 12 months
months = ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
nyc = [30, 32, 40, 52, 65, 75, 82, 81, 74, 63, 50, 38]
miami = [65, 66, 70, 76, 82, 87, 90, 90, 87, 80, 72, 66]
chicago = [25, 27, 35, 48, 62, 72, 80, 79, 71, 60, 45, 32]

# Create figure with enhanced styling

Turn Predictions into a Clear Performance Figure

Build a ROC curve from your own scores and labels, report the AUC, and export a figure that is ready for a paper, model card, or clinical report.