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

Function test_pairwise_effect

crates/openquant/tests/fingerprint.rs:98–116  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

96
97#[test]
98fn test_pairwise_effect() {
99 let x = synthetic_x(100, 13);
100 let pairs = vec![(0usize, 2usize), (1, 3), (5, 7)];
101 let mut fp = RegressionModelFingerprint::new();
102
103 fp.fit(&NonLinearRegModel, &x, 20, Some(&pairs)).unwrap();
104 let (_, _, pairwise) = fp.get_effects().unwrap();
105 let p = pairwise.unwrap();
106 assert!(p.raw["(0, 2)"] > 0.01);
107
108 let linear = LinearRegModel { w: vec![1.0; 13] };
109 fp.fit(&linear, &x, 20, Some(&pairs)).unwrap();
110 let (_, _, pairwise_linear) = fp.get_effects().unwrap();
111 let p_lin = pairwise_linear.unwrap();
112 for pair in &pairs {
113 let key = format!("({}, {})", pair.0, pair.1);
114 assert!(p_lin.raw[&key].abs() < 1e-9);
115 }
116}
117
118#[test]
119fn test_classification_fingerprint() {

Callers

nothing calls this directly

Calls 3

synthetic_xFunction · 0.85
get_effectsMethod · 0.80
fitMethod · 0.45

Tested by

no test coverage detected