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

Method predict

crates/openquant/src/sb_bagging.rs:233–250  ·  view source on GitHub ↗
(&self, x: &DMatrix<f64>)

Source from the content-addressed store, hash-verified

231 }
232
233 pub fn predict(&self, x: &DMatrix<f64>) -> Result<Vec<u8>, SbBaggingError> {
234 if self.estimators.is_empty() {
235 return Err(SbBaggingError::EmptyInput);
236 }
237 let mut out = vec![0u8; x.nrows()];
238 for r in 0..x.nrows() {
239 let mut votes = 0usize;
240 for est in &self.estimators {
241 let ge = x[(r, est.feature_idx)] >= est.threshold;
242 let pred_one = if est.positive_on_ge { ge } else { !ge };
243 if pred_one {
244 votes += 1;
245 }
246 }
247 out[r] = if votes * 2 >= self.estimators.len() { 1 } else { 0 };
248 }
249 Ok(out)
250 }
251}
252
253#[derive(Debug, Clone)]

Callers 5

score_modelFunction · 0.45
fitMethod · 0.45
fitMethod · 0.45
sb_fit_predict_regressorFunction · 0.45

Calls 2

is_emptyMethod · 0.80
lenMethod · 0.80

Tested by

no test coverage detected