pub fn average_pairwise_prediction_correlation(
per_model_predictions: &[Vec<f64>],
) -> Result<f64, EnsembleError>Expand description
Mean Pearson correlation over all pairs of model rows: the ρ̄ of AFML §6.3.1.
Pass the models’ errors (residuals), or predictions of a de-meaned target, to get the
ρ̄ that bagging_ensemble_variance means; on raw predictions of a common target this
mostly measures that every model tracks the target. A pair involving a constant row
contributes a correlation of 0.
use openquant::ensemble_methods::average_pairwise_prediction_correlation;
// Pair correlations are +1, -1 and -1.
let rows = [vec![1.0, 2.0, 3.0], vec![2.0, 4.0, 6.0], vec![3.0, 2.0, 1.0]];
let rho = average_pairwise_prediction_correlation(&rows)?;
assert!((rho + 1.0 / 3.0).abs() < 1e-12);§Errors
EnsembleError::TooFewModelsif there are fewer than two rows.EnsembleError::TooFewPredictionSamplesif the first row has fewer than two entries.EnsembleError::LengthMismatch("prediction")if the rows differ in length.