Struct linfa_svm::SvmParams[][src]

pub struct SvmParams<F: Float, T> { /* fields omitted */ }

SVM Hyperparameters

The SVM fitting process can be controlled in different ways. For classification the C and Nu parameters control the ratio of support vectors and accuracy, eps controls the required precision. After setting the desired parameters a model can be fitted by calling fit.

You can specify the expected return type with the turbofish syntax. If you want to enable Platt-Scaling for proper probability values, then use:

let model = Svm::<_, Pr>::params();

or bool if you only wants to know the binary decision:

let model = Svm::<_, bool>::params();

Example

let model = Svm::params()
    .eps(0.1f64)
    .shrinking(true)
    .nu_weight(0.1)
    .fit(&dataset);

Implementations

impl<F: Float, T> SvmParams<F, T>[src]

pub fn eps(self, new_eps: F) -> Self[src]

Set stopping condition

This parameter controls the stopping condition. It checks whether the sum of gradients of the max violating pair is below this threshold and then stops the optimization proces.

pub fn shrinking(self, shrinking: bool) -> Self[src]

Shrink active variable set

This parameter controls whether the active variable set is shrinked or not. This can speed up the optimization process, but may degredade the solution performance.

pub fn with_kernel_params(self, kernel: KernelParams<F>) -> Self[src]

Set the kernel to use for training

This parameter specifies a mapping of input records to a new feature space by means of the distance function between any couple of points mapped to such new space. The SVM then applies a linear separation in the new feature space that may result in a non linear partitioning of the original input space, thus increasing the expressiveness of this model. To use the “base” SVM model it suffices to choose a Linear kernel.

pub fn with_platt_params(self, platt: PlattParams<F, ()>) -> Self[src]

Set the platt params for probability calibration

pub fn gaussian_kernel(self, eps: F) -> Self[src]

Sets the model to use the Gaussian kernel. For this kernel the distance between two points is computed as: d(x, x') = exp(-norm(x - x')/eps)

pub fn polynomial_kernel(self, constant: F, degree: F) -> Self[src]

Sets the model to use the Polynomial kernel. For this kernel the distance between two points is computed as: d(x, x') = (<x, x'> + costant)^(degree)

pub fn linear_kernel(self) -> Self[src]

Sets the model to use the Linear kernel. For this kernel the distance between two points is computed as : d(x, x') = <x, x'>

impl<F: Float, T> SvmParams<F, T>[src]

pub fn pos_neg_weights(self, c_pos: F, c_neg: F) -> Self[src]

Set the C value for positive and negative samples.

pub fn nu_weight(self, nu: F) -> Self[src]

Set the Nu value for classification

The Nu value should lie in range [0, 1] and sets the relation between support vectors and solution performance.

impl<F: Float> SvmParams<F, F>[src]

pub fn c_eps(self, c: F, eps: F) -> Self[src]

Set the C value for regression

pub fn nu_eps(self, nu: F, eps: F) -> Self[src]

Set the Nu-Eps value for regression

Trait Implementations

impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<()>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, Pr>[src]

type Object = Svm<F, bool>

impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, Pr>[src]

type Object = Svm<F, Pr>

impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, bool>[src]

type Object = Svm<F, bool>

impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CountedTargets<(), ArrayBase<OwnedRepr<()>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, Pr>[src]

type Object = Svm<F, bool>

impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CountedTargets<(), ArrayBase<ViewRepr<&'_ ()>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, Pr>[src]

type Object = Svm<F, bool>

impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, Pr>[src]

type Object = Svm<F, Pr>

impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, bool>[src]

type Object = Svm<F, bool>

impl Fit<ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f32>, Dim<[usize; 1]>>, SvmResult> for SvmParams<f32, f32>[src]

type Object = Svm<f32, f32>

impl Fit<ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, SvmResult> for SvmParams<f32, f32>[src]

type Object = Svm<f32, f32>

impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, SvmResult> for SvmParams<f64, f64>[src]

type Object = Svm<f64, f64>

impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, SvmResult> for SvmParams<f64, f64>[src]

type Object = Svm<f64, f64>

impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&'_ ()>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, Pr>[src]

type Object = Svm<F, bool>

impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&'_ bool>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, Pr>[src]

type Object = Svm<F, Pr>

impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&'_ bool>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, bool>[src]

type Object = Svm<F, bool>

impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, Pr>[src]

type Object = Svm<F, Pr>

impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, bool>[src]

type Object = Svm<F, bool>

impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<ViewRepr<&'_ bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, Pr>[src]

type Object = Svm<F, Pr>

impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<ViewRepr<&'_ bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, bool>[src]

type Object = Svm<F, bool>

impl Fit<ArrayBase<ViewRepr<&'_ f32>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&'_ f32>, Dim<[usize; 1]>>, SvmResult> for SvmParams<f32, f32>[src]

type Object = Svm<f32, f32>

impl Fit<ArrayBase<ViewRepr<&'_ f32>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&'_ f32>, Dim<[usize; 2]>>, SvmResult> for SvmParams<f32, f32>[src]

type Object = Svm<f32, f32>

impl Fit<ArrayBase<ViewRepr<&'_ f64>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&'_ f64>, Dim<[usize; 1]>>, SvmResult> for SvmParams<f64, f64>[src]

type Object = Svm<f64, f64>

impl Fit<ArrayBase<ViewRepr<&'_ f64>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&'_ f64>, Dim<[usize; 2]>>, SvmResult> for SvmParams<f64, f64>[src]

type Object = Svm<f64, f64>

Auto Trait Implementations

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

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

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

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

impl<F, T> UnwindSafe for SvmParams<F, T> where
    F: UnwindSafe,
    T: UnwindSafe

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> Same<T> for T

type Output = T

Should always be Self

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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