Skip to contents

A convenience function to compute only the ECE from responsibilities and true labels.

Usage

compute_ece(resp, z_true, n_bins = 10)

Arguments

resp

Matrix of responsibilities (N x K)

z_true

Integer vector of true cluster labels (length N)

n_bins

Number of bins. Default: 10.

Value

Numeric scalar, the ECE value. Lower is better (0 = perfect calibration).

Details

ECE measures the average absolute difference between predicted probabilities and observed frequencies. A value of 0 indicates perfect calibration; values above 0.1 suggest significant miscalibration.

Guidelines for interpretation:

  • ECE < 0.02: Excellent calibration

  • ECE 0.02-0.05: Good calibration

  • ECE 0.05-0.10: Moderate calibration

  • ECE > 0.10: Poor calibration

Examples

if (FALSE) { # \dontrun{
ece <- compute_ece(fit$resp, z_true)
cat(sprintf("ECE: %.3f\n", ece))
} # }