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

Method fit

crates/openquant/src/fingerprint.rs:42–55  ·  view source on GitHub ↗
(
        &mut self,
        model: &M,
        x: &[Vec<f64>],
        num_values: usize,
        pairwise_combinations: Option<&[(usize, usize)]>,
    )

Source from the content-addressed store, hash-verified

40//! for &c in &grid {
41//! x.push(vec![a, b, c]);
42//! }
43//! }
44//! }
45//!
46//! let mut fingerprint = RegressionModelFingerprint::new();
47//! fingerprint.fit(&Known, &x, 11, Some(&[(0, 2), (0, 1)]))?;
48//! let (linear, non_linear, pairwise) = fingerprint.get_effects()?;
49//! let pairwise = pairwise.expect("pairs were requested");
50//!
51//! // Mean |2 v| over the grid is 12/11.
52//! assert!((linear.raw[&0] - 12.0 / 11.0).abs() < 1e-9);
53//! assert!(linear.raw[&1] < 1e-9 && non_linear.norm[&1] > 0.999);
54//! assert!(linear.raw[&2] < 1e-9 && non_linear.raw[&2] < 1e-9);
55//! // The interaction is x0 x2 itself: mean |v w| = (6/11)^2.
56//! assert!((pairwise.raw["(0, 2)"] - 36.0 / 121.0).abs() < 1e-9);
57//! assert!(pairwise.raw["(0, 1)"] < 1e-9);
58//! # Ok(())

Callers

nothing calls this directly

Calls 3

fit_implFunction · 0.85
predictMethod · 0.45
predict_probaMethod · 0.45

Tested by

no test coverage detected