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

Function get_linear_effect

crates/openquant/src/fingerprint.rs:203–217  ·  view source on GitHub ↗
(
    feature_values: &[Vec<f64>],
    partial_dep: &[Vec<f64>],
)

Source from the content-addressed store, hash-verified

201 }
202 let pred = predictor(&x_mod);
203 out[j][k] = pred.iter().sum::<f64>() / pred.len() as f64;
204 }
205 }
206 out
207}
208
209fn get_linear_effect(
210 feature_values: &[Vec<f64>],
211 partial_dep: &[Vec<f64>],
212) -> BTreeMap<usize, f64> {
213 let mut store = BTreeMap::new();
214 for j in 0..feature_values.len() {
215 let x = &feature_values[j];
216 let y = &partial_dep[j];
217 let (a, b) = ols_line(x, y);
218 let y_mean = y.iter().sum::<f64>() / y.len() as f64;
219 let effect = x.iter().map(|v| (a + b * *v - y_mean).abs()).sum::<f64>() / x.len() as f64;
220 store.insert(j, effect);

Callers 1

fit_implFunction · 0.85

Calls 2

ols_lineFunction · 0.85
lenMethod · 0.80

Tested by

no test coverage detected