civic_compare: Compare multiple civic_models on a shared test set

View source: R/civic_scorecard.R

civic_compareR Documentation

Compare multiple civic_models on a shared test set

Description

Evaluates a named list of 'civic_model' objects on a common test set and returns a tidy comparison table of performance, fairness, and interpretability. All models must have the same task type.

Usage

civic_compare(
  models,
  test_data,
  outcome,
  protected = NULL,
  positive = NULL,
  threshold = 0.5
)

Arguments

models

A **named** list of 'civic_model' objects, e.g. 'list(CART = m1, Logistic = m2)'.

test_data

A data frame used for all evaluations.

outcome

Character. Outcome column name.

protected

Character. Protected attribute column (optional). Pass 'NULL' to skip fairness metrics.

positive

Positive class level (binary only).

threshold

Decision threshold (binary only, default '0.5').

Value

A tibble of class 'civic_comparison'.

Examples

splits <- civic_split(iris, stratify = "Species")
m1 <- civic_fit(Species ~ ., splits$train, model = "cart")
m2 <- civic_fit(Species ~ ., splits$train, model = "multinomial")
cmp <- civic_compare(list(CART = m1, Multinomial = m2),
                     splits$test, outcome = "Species")
civic_plot_comparison(cmp)

civic.icarm documentation built on June 18, 2026, 1:06 a.m.