MCPcopy Create free account
hub / github.com/Open-Quant/openquant / bagging_ensemble_variance

Function bagging_ensemble_variance

crates/openquant/src/ensemble_methods.rs:207–225  ·  view source on GitHub ↗
(
    single_estimator_variance: f64,
    average_correlation: f64,
    n_estimators: usize,
)

Source from the content-addressed store, hash-verified

205}
206
207pub fn bagging_ensemble_variance(
208 single_estimator_variance: f64,
209 average_correlation: f64,
210 n_estimators: usize,
211) -> Result<f64, String> {
212 if single_estimator_variance < 0.0 {
213 return Err("single_estimator_variance must be non-negative".to_string());
214 }
215 if !(-1.0..=1.0).contains(&average_correlation) {
216 return Err("average_correlation must be in [-1,1]".to_string());
217 }
218 if n_estimators == 0 {
219 return Err("n_estimators must be > 0".to_string());
220 }
221
222 let n = n_estimators as f64;
223 let rho = average_correlation;
224 Ok(single_estimator_variance * (rho + (1.0 - rho) / n))
225}
226
227pub fn recommend_bagging_vs_boosting(
228 base_estimator_accuracy: f64,

Calls

no outgoing calls