Skip to main content

Svm

Struct Svm 

Source
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

Source

pub fn new_svc() -> Result<Self>

Build a C-SVC classifier in f64 precision.

Source

pub fn new_nu_svc() -> Result<Self>

Build a Nu-SVC classifier in f64 precision.

Source

pub fn new_svr() -> Result<Self>

Build an epsilon-SVR regressor in f64 precision.

Source

pub fn new_nu_svr() -> Result<Self>

Build a Nu-SVR regressor in f64 precision.

Source

pub fn handle_mut(&mut self) -> &mut Handle

Borrow the underlying handle to set SVM-specific options.

Source

pub fn kind(&self) -> SvmKind

Family of SVM model that this handle was constructed for.

Source

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.

Source

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.

Source

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.

Source

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.

Trait Implementations§

Source§

impl Debug for Svm

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl !Freeze for Svm

§

impl !RefUnwindSafe for Svm

§

impl !Sync for Svm

§

impl Forget for Svm

§

impl Move for Svm

§

impl Send for Svm
where Handle: Send,

§

impl Unpin for Svm

§

impl UnsafeUnpin for Svm

§

impl UnwindSafe for Svm

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.