Struct linfa_svm::Svm

source ·
pub struct Svm<F: Float, T> {
    pub alpha: Vec<F>,
    pub rho: F,
    /* private fields */
}
Expand description

Fitted Support Vector Machines model

This is the result of the SMO optimizer and contains the support vectors, quality of solution and optionally the linear hyperplane.

Fields§

§alpha: Vec<F>§rho: F

Implementations§

source§

impl<F: Float, L> Svm<F, L>

source

pub fn params() -> SvmParams<F, L>

source§

impl<F: Float, T> Svm<F, T>

source

pub fn nsupport(&self) -> usize

Returns the number of support vectors

This function returns the number of support vectors which have an influence on the decision outcome greater than zero.

source

pub fn weighted_sum<D: Data<Elem = F>>(&self, sample: &ArrayBase<D, Ix1>) -> F

Sums the inner product of sample and every one of the support vectors.

Parameters
  • sample: the input sample
Returns

The sum of all inner products of sample and every one of the support vectors, scaled by their weight.

Panics

If the shape of sample is not compatible with the shape of the support vectors

Trait Implementations§

source§

impl<F: Clone + Float, T: Clone> Clone for Svm<F, T>

source§

fn clone(&self) -> Svm<F, T>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<F: Debug + Float, T: Debug> Debug for Svm<F, T>

source§

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

Formats the value using the given formatter. Read more
source§

impl<'a, F: Float, T> Display for Svm<F, T>

Display solution

In order to understand the solution of the SMO solver the objective, number of iterations and required support vectors are printed here.

source§

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

Formats the value using the given formatter. Read more
source§

impl<F: PartialEq + Float, T: PartialEq> PartialEq for Svm<F, T>

source§

fn eq(&self, other: &Svm<F, T>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<F: Float, D: Data<Elem = F>> Predict<ArrayBase<D, Dim<[usize; 1]>>, Pr> for Svm<F, Pr>

Predict a probability with a feature vector

source§

fn predict(&self, data: ArrayBase<D, Ix1>) -> Pr

source§

impl<'a, F: Float, D: Data<Elem = F>> Predict<ArrayBase<D, Dim<[usize; 1]>>, bool> for Svm<F, bool>

Predict a probability with a feature vector

source§

fn predict(&self, data: ArrayBase<D, Ix1>) -> bool

source§

impl Predict<ArrayBase<OwnedRepr<f32>, Dim<[usize; 1]>>, f32> for Svm<f32, f32>

Predict a probability with a feature vector

source§

fn predict(&self, data: Array1<f32>) -> f32

source§

impl Predict<ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, f64> for Svm<f64, f64>

Predict a probability with a feature vector

source§

fn predict(&self, data: Array1<f64>) -> f64

source§

impl<'a> Predict<ArrayBase<ViewRepr<&'a f32>, Dim<[usize; 1]>>, f32> for Svm<f32, f32>

Predict a probability with a feature vector

source§

fn predict(&self, data: ArrayView1<'a, f32>) -> f32

source§

impl<'a> Predict<ArrayBase<ViewRepr<&'a f64>, Dim<[usize; 1]>>, f64> for Svm<f64, f64>

Predict a probability with a feature vector

source§

fn predict(&self, data: ArrayView1<'a, f64>) -> f64

source§

impl<F: Float, D: Data<Elem = F>> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<Pr>, Dim<[usize; 1]>>> for Svm<F, Pr>

Predict a probability with a feature vector Classify observations

This function takes a number of features and predicts target probabilities that they belong to the positive class.

source§

fn predict_inplace(&self, data: &ArrayBase<D, Ix2>, targets: &mut Array1<Pr>)

Predict something in place
source§

fn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array1<Pr>

Create targets that predict_inplace works with.
source§

impl<F: Float, D: Data<Elem = F>> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<bool>, Dim<[usize; 1]>>> for Svm<F, bool>

Classify observations

This function takes a number of features and predicts target probabilities that they belong to the positive class.

source§

fn predict_inplace(&self, data: &ArrayBase<D, Ix2>, targets: &mut Array1<bool>)

Predict something in place
source§

fn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array1<bool>

Create targets that predict_inplace works with.
source§

impl<D: Data<Elem = f32>> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f32>, Dim<[usize; 1]>>> for Svm<f32, f32>

Classify observations

This function takes a number of features and predicts target probabilities that they belong to the positive class.

source§

fn predict_inplace<'a>( &'a self, data: &ArrayBase<D, Ix2>, targets: &mut Array1<f32> )

Predict something in place
source§

fn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array1<f32>

Create targets that predict_inplace works with.
source§

impl<D: Data<Elem = f64>> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>> for Svm<f64, f64>

Classify observations

This function takes a number of features and predicts target probabilities that they belong to the positive class.

source§

fn predict_inplace<'a>( &'a self, data: &ArrayBase<D, Ix2>, targets: &mut Array1<f64> )

Predict something in place
source§

fn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array1<f64>

Create targets that predict_inplace works with.
source§

impl<F: Float, T> StructuralPartialEq for Svm<F, T>

Auto Trait Implementations§

§

impl<F, T> RefUnwindSafe for Svm<F, T>where F: RefUnwindSafe, T: RefUnwindSafe,

§

impl<F, T> Send for Svm<F, T>where T: Send,

§

impl<F, T> Sync for Svm<F, T>where T: Sync,

§

impl<F, T> Unpin for Svm<F, T>where T: Unpin,

§

impl<F, T> UnwindSafe for Svm<F, T>where F: UnwindSafe + RefUnwindSafe, T: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for Twhere 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 Twhere 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<'a, F, D, DM, T, O> Predict<&'a ArrayBase<D, DM>, T> for Owhere D: Data<Elem = F>, DM: Dimension, O: PredictInplace<ArrayBase<D, DM>, T>,

source§

fn predict(&self, records: &'a ArrayBase<D, DM>) -> T

source§

impl<'a, F, R, T, S, O> Predict<&'a DatasetBase<R, T>, S> for Owhere R: Records<Elem = F>, O: PredictInplace<R, S>,

source§

fn predict(&self, ds: &'a DatasetBase<R, T>) -> S

source§

impl<F, D, E, T, O> Predict<ArrayBase<D, Dim<[usize; 2]>>, DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>> for Owhere D: Data<Elem = F>, T: AsTargets<Elem = E>, O: PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, T>,

source§

fn predict( &self, records: ArrayBase<D, Dim<[usize; 2]>> ) -> DatasetBase<ArrayBase<D, Dim<[usize; 2]>>, T>

source§

impl<F, R, T, E, S, O> Predict<DatasetBase<R, T>, DatasetBase<R, S>> for Owhere R: Records<Elem = F>, S: AsTargets<Elem = E>, O: PredictInplace<R, S>,

source§

fn predict(&self, ds: DatasetBase<R, T>) -> DatasetBase<R, S>

source§

impl<T> ToOwned for Twhere T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T> ToString for Twhere T: Display + ?Sized,

source§

default fn to_string(&self) -> String

Converts the given value to a String. Read more
source§

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

§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

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

§

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.
§

impl<V, T> VZip<V> for Twhere V: MultiLane<T>,

§

fn vzip(self) -> V