1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
//! # anofox-ml SVM
//!
//! Support Vector Machine classifiers for the anofox-ml machine learning library.
//!
//! This crate provides two SVM classifiers:
//!
//! - [`LinearSvc`] -- Linear Support Vector Classifier using hinge loss + L2
//! regularization, solved via coordinate descent (similar to sklearn's
//! `LinearSVC` with liblinear).
//! - [`Svc`] -- Support Vector Classifier with kernel support (linear, RBF,
//! polynomial), solved via a simplified SMO algorithm.
//!
//! Both classifiers support binary and multi-class classification (via
//! one-vs-rest strategy).
//!
//! ## Example
//!
//! ```rust
//! use anofox_ml_core::{Fit, Predict};
//! use anofox_ml_svm::{LinearSvc, Svc, SvmKernel};
//! use ndarray::array;
//!
//! // Linear SVC
//! let x = array![[0.0, 0.0], [0.1, 0.1], [5.0, 5.0], [5.1, 5.1]];
//! let y = array![0.0, 0.0, 1.0, 1.0];
//!
//! let svc = LinearSvc::new().with_c(1.0);
//! let model = svc.fit(&x, &y).unwrap();
//! let preds = model.predict(&x).unwrap();
//!
//! // Kernel SVC with RBF
//! let svc = Svc::new()
//! .with_kernel(SvmKernel::Rbf { gamma: 0.5 })
//! .with_c(10.0);
//! let model = svc.fit(&x, &y).unwrap();
//! let preds = model.predict(&x).unwrap();
//! ```
pub use SvmKernel;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;
pub use ;