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

Method fit

crates/openquant/tests/hyperparameter_tuning.rs:43–54  ·  view source on GitHub ↗
(&mut self, _x: &[Vec<f64>], y: &[f64], sample_weight: Option<&[f64]>)

Source from the content-addressed store, hash-verified

41
42impl SimpleClassifier for ThresholdClassifier {
43 fn fit(&mut self, _x: &[Vec<f64>], y: &[f64], sample_weight: Option<&[f64]>) {
44 let mut total_w = 0.0;
45 let mut pos_w = 0.0;
46 for (i, yi) in y.iter().enumerate() {
47 let w = sample_weight.map(|sw| sw[i]).unwrap_or(1.0);
48 total_w += w;
49 if *yi == 1.0 {
50 pos_w += w;
51 }
52 }
53 self.trained_prior = if total_w > 0.0 { pos_w / total_w } else { 0.5 };
54 }
55
56 fn predict_proba(&self, x: &[Vec<f64>]) -> Vec<f64> {
57 x.iter()

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected