Bundled competing-risks evaluation: concordance, Brier, and integrated Brier.
score_cr(
surv,
incidence_prob,
*,
data=None,
cause,
times,
tau=None,
conf_level=0.95,
format=None,
)
Computes the main prediction-performance metrics for a cause-specific cumulative incidence model in one call, returning a tidy summary frame.
Parameters
surv: Surv | Outcome | str
-
A multistate Surv response. An Outcome or a formula response such as 'Surv(time, status == 2)' is also accepted, with its columns read from data.
incidence_prob: Any
-
Predicted CIF for the cause of interest, shape (n_subjects, n_times).
cause: int
-
Integer cause code.
times: Any
-
Evaluation times (1-D array-like), matching the columns of incidence_prob.
tau: float | None = None
-
Truncation time for the concordance index. Defaults to the last value in times.
conf_level: float = 0.95
-
Confidence level for the concordance CI.
format: str | None = None
-
DataFrame backend for the returned table.
data: Any = None
-
A data frame (pandas, Polars, PyArrow, DuckDB, a lazy frame, …) holding the columns named by the response and
incidence_prob. When surv is an Outcome or a formula, rows with a missing value in any column used are dropped first, along with the matching rows of any arrays passed alongside.
Returns
DataFrame
-
One row per metric with columns
metric, estimate, and (for the concordance) se, conf_low, conf_high.
Examples
import greenwood as gw
import numpy as np
mg = gw.load_dataset("mgus2", backend="polars")
first = gw.Outcome.first_event(
endpoints={"pcm": ("ptime", "pstat"), "death": ("futime", "death")}
)
fg = gw.FineGray(cause="pcm").fit(first, covariates=["age", "sex"], data=mg)
eval_times = np.array([120, 240, 360])
cif_pred = fg.predict_cumulative_incidence(
mg, times=eval_times, format="pandas"
).drop(columns="time").values.T
gw.score_cr(
first, incidence_prob=cif_pred, cause=1, times=eval_times, data=mg, format="polars"
)
shape: (5, 5)| metric | estimate | se | conf_low | conf_high |
|---|
| str | f64 | f64 | f64 | f64 |
| "concordance" | 0.664422 | 0.044569 | 0.57231 | 0.745517 |
| "brier(120)" | 0.087738 | NaN | NaN | NaN |
| "brier(240)" | 0.147587 | NaN | NaN | NaN |
| "brier(360)" | 0.199861 | NaN | NaN | NaN |
| "integrated_brier" | 0.145693 | NaN | NaN | NaN |