MCPcopy Create free account
hub / github.com/brainflow-dev/brainflow / predict

Method predict

rust_package/brainflow/src/ml_model.rs:32–48  ·  view source on GitHub ↗

Calculate metric from data.

(&self, data: &mut [f64])

Source from the content-addressed store, hash-verified

30
31 /// Calculate metric from data.
32 pub fn predict(&self, data: &mut [f64]) -> Result<Vec<f64>> {
33 let mut output: Vec<f64> = Vec::with_capacity(*self.model_params.max_array_size());
34 let mut output_len = 0;
35 let res = unsafe {
36 ml_module::predict(
37 data.as_mut_ptr() as *mut c_double,
38 data.len() as c_int,
39 output.as_mut_ptr(),
40 &mut output_len,
41 self.json_model_params.as_ptr(),
42 )
43 };
44 check_brainflow_exit_code(res)?;
45 unsafe { output.set_len(output_len as usize) };
46 let output_casted = output.into_iter().map(|c| c as f64).collect::<Vec<f64>>();
47 Ok(output_casted)
48 }
49
50 /// Release classifier.
51 pub fn release(&self) -> Result<()> {

Callers

nothing calls this directly

Calls 3

max_array_sizeMethod · 0.80
predictFunction · 0.50

Tested by

no test coverage detected