pub struct Svm { /* private fields */ }Expand description
Support vector machine wrapper covering both classification (Svc,
NuSvc) and regression (Svr, NuSvr) modes. Configure
SVM-specific options (kernel, C, epsilon, gamma, …) via
Svm::handle_mut before calling Svm::fit.
Implementations§
Source§impl Svm
impl Svm
Sourcepub fn new_nu_svc() -> Result<Self>
pub fn new_nu_svc() -> Result<Self>
Build a Nu-SVC classifier in f64 precision.
Sourcepub fn new_nu_svr() -> Result<Self>
pub fn new_nu_svr() -> Result<Self>
Build a Nu-SVR regressor in f64 precision.
Sourcepub fn handle_mut(&mut self) -> &mut Handle
pub fn handle_mut(&mut self) -> &mut Handle
Borrow the underlying handle to set SVM-specific options.
Sourcepub fn fit(
&mut self,
n_samples: usize,
n_features: usize,
x: &[f64],
y: &[f64],
) -> Result<()>
pub fn fit( &mut self, n_samples: usize, n_features: usize, x: &[f64], y: &[f64], ) -> Result<()>
Fit on column-major n_samples × n_features features x and a
length-n_samples response vector y. For classification, y
holds class indices 0..n_class-1 (as floats); for regression
it holds the real target.
Sourcepub fn predict(
&mut self,
n_samples: usize,
n_features: usize,
x_test: &[f64],
predictions: &mut [f64],
) -> Result<()>
pub fn predict( &mut self, n_samples: usize, n_features: usize, x_test: &[f64], predictions: &mut [f64], ) -> Result<()>
Predict labels (classification) or values (regression) for new
data. predictions receives n_samples outputs.
Sourcepub fn score(
&mut self,
n_samples: usize,
n_features: usize,
x_test: &[f64],
y_test: &[f64],
) -> Result<f64>
pub fn score( &mut self, n_samples: usize, n_features: usize, x_test: &[f64], y_test: &[f64], ) -> Result<f64>
Compute the model’s score: accuracy for classification or R²
for regression.
Sourcepub fn decision_function(
&mut self,
n_samples: usize,
n_features: usize,
x_test: &[f64],
shape: DecisionShape,
decision_values: &mut [f64],
ldd: usize,
) -> Result<()>
pub fn decision_function( &mut self, n_samples: usize, n_features: usize, x_test: &[f64], shape: DecisionShape, decision_values: &mut [f64], ldd: usize, ) -> Result<()>
Compute the SVM decision function on test data (classification
only; for regression call Svm::predict directly). Output
layout depends on shape and n_class; see AOCL docs for the
exact size requirements.