Getting Started
rtichoke is a Python library for interactive visualization of predictive-model performance. It supports discrimination, calibration, utility, and time-to-event evaluation workflows.
For some reproducible examples please visit rtichoke blog!
Installation
If you use uv to manage your Python project, add rtichoke with:
uv add rtichokeThis adds rtichoke to your project dependencies and updates the uv lockfile.
If you are not using uv, install rtichoke from PyPI with pip:
pip install rtichokeImport
import numpy as np
import rtichoke as rkInputs
Most rtichoke plotting functions use two dictionaries:
probs: model predictions, keyed by model or population name.reals: observed outcomes, keyed by population name.
Similar curve families can still differ in defaults and time-dependent handling. See Curve API Compatibility, and if a call fails, search Common Errors & Fixes by literal exception text.
Single model
probs_single = {
"Model A": np.array([0.1, 0.9, 0.4, 0.8, 0.3, 0.7, 0.2, 0.6])
}
reals_single = {
"Population": np.array([0, 1, 0, 1, 0, 1, 0, 1])
}
fig = rk.create_roc_curve(
probs=probs_single,
reals=reals_single,
)
fig.show()Compare models
When several models are evaluated on the same population, provide one probability vector per model and one outcome vector for the shared population.
probs_comparison = {
"Model A": np.array([0.1, 0.9, 0.2, 0.8, 0.3, 0.7]),
"Model B": np.array([0.2, 0.8, 0.3, 0.7, 0.4, 0.6]),
"Random Guess": np.array([0.5, 0.5, 0.5, 0.5, 0.5, 0.5]),
}
reals_comparison = {
"Population": np.array([0, 1, 0, 1, 0, 1])
}
fig = rk.create_precision_recall_curve(
probs=probs_comparison,
reals=reals_comparison,
)
fig.show()Compare populations
To compare a model across populations, provide matching keys in probs and reals. Population sizes may differ; each probability vector only needs to match the outcome vector for the same key.
probs_populations = {
"Train": np.array([0.1, 0.9, 0.2, 0.8, 0.3, 0.7]),
"Test": np.array([0.2, 0.8, 0.3, 0.7]),
}
reals_populations = {
"Train": np.array([0, 1, 0, 1, 0, 1]),
"Test": np.array([0, 1, 0, 0]),
}
fig = rk.create_calibration_curve(
probs=probs_populations,
reals=reals_populations,
)
fig.show()Here, Train contains six observations and Test contains four. This matching-key contract is supported by calibration as well as the other curve families.
From here, use the API Reference for the full set of curve types, parameters, and time-to-event variants. The Naming Conventions guide explains how the exported function families fit together, while Curve API Compatibility documents where those families still differ.