From dbdaeaf9fd51d3486f985c745532d19843ba0b3d Mon Sep 17 00:00:00 2001 From: Montana Low Date: Fri, 16 Sep 2022 09:55:06 -0700 Subject: [PATCH] create a test case for the issue --- src/svm/svc.rs | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/src/svm/svc.rs b/src/svm/svc.rs index 74f31c74..612a48a5 100644 --- a/src/svm/svc.rs +++ b/src/svm/svc.rs @@ -863,6 +863,30 @@ mod tests { assert!(accuracy(&y_hat, &y) >= 0.9); } + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] + #[test] + fn svc_fit_predict_c() { + let breast_cancer = crate::dataset::breast_cancer::load_dataset(); + let y = breast_cancer.target; + let x = DenseMatrix::from_array( + breast_cancer.num_samples, + breast_cancer.num_features, + &breast_cancer.data, + ); + + let y_hat = SVC::fit( + &x, + &y, + SVCParameters::default() + .with_c(10.0) + .with_kernel(Kernels::linear()), + ) + .and_then(|lr| lr.predict(&x)) + .unwrap(); + + assert!(accuracy(&y_hat, &y) >= 0.9); + } + #[cfg_attr(target_arch = "wasm32", wasm_bindgen_test::wasm_bindgen_test)] #[test] #[cfg(feature = "serde")]