(
py: Python<'_>,
x: Vec<Vec<f64>>,
y: Vec<u8>,
ind_mat: Vec<Vec<u8>>,
n_estimators: usize,
max_samples: f64,
max_features: f64,
random_state: u64,
sample_weight: O
| 15 | sample_weight=None |
| 16 | ))] |
| 17 | fn sb_fit_predict_classifier( |
| 18 | py: Python<'_>, |
| 19 | x: Vec<Vec<f64>>, |
| 20 | y: Vec<u8>, |
| 21 | ind_mat: Vec<Vec<u8>>, |
| 22 | n_estimators: usize, |
| 23 | max_samples: f64, |
| 24 | max_features: f64, |
| 25 | random_state: u64, |
| 26 | sample_weight: Option<Vec<f64>>, |
| 27 | ) -> PyResult<PyObject> { |
| 28 | let x_mat = matrix_from_rows(x)?; |
| 29 | |
| 30 | let mut clf = |
| 31 | openquant::sb_bagging::SequentiallyBootstrappedBaggingClassifier::new(random_state); |
| 32 | clf.n_estimators = n_estimators; |
| 33 | clf.max_samples = openquant::sb_bagging::MaxSamples::Float(max_samples); |
| 34 | clf.max_features = openquant::sb_bagging::MaxFeatures::Float(max_features); |
| 35 | clf.oob_score = true; |
| 36 | |
| 37 | clf.fit(&x_mat, &y, &ind_mat, sample_weight.as_deref()).map_err(to_py_err)?; |
| 38 | let predictions = clf.predict(&x_mat).map_err(to_py_err)?; |
| 39 | |
| 40 | let d = PyDict::new(py); |
| 41 | d.set_item("predictions", predictions)?; |
| 42 | d.set_item("oob_score", clf.oob_score_value)?; |
| 43 | Ok(d.into_pyobject(py).unwrap().into_any().unbind()) |
| 44 | } |
| 45 | |
| 46 | #[pyfunction(name = "fit_predict_sb_regressor")] |
nothing calls this directly
no test coverage detected