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]
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]
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.
Trait Implementations
impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<()>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, Pr>
[src]
impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<()>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, Pr>
[src]impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, Pr>
[src]
impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, Pr>
[src]impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, bool>
[src]
impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, bool>
[src]impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CountedTargets<(), ArrayBase<OwnedRepr<()>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, Pr>
[src]
impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CountedTargets<(), ArrayBase<OwnedRepr<()>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, Pr>
[src]impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CountedTargets<(), ArrayBase<ViewRepr<&'_ ()>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, Pr>
[src]
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>
fn fit(
&self,
dataset: &DatasetBase<Array2<F>, CountedTargets<(), ArrayView2<'_, ()>>>
) -> Result<Self::Object>
[src]
&self,
dataset: &DatasetBase<Array2<F>, CountedTargets<(), ArrayView2<'_, ()>>>
) -> Result<Self::Object>
impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, Pr>
[src]
impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, Pr>
[src]impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, bool>
[src]
impl<F: Float> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, bool>
[src]impl Fit<ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f32>, Dim<[usize; 1]>>, SvmResult> for SvmParams<f32, f32>
[src]
impl Fit<ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f32>, Dim<[usize; 1]>>, SvmResult> for SvmParams<f32, f32>
[src]impl Fit<ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, SvmResult> for SvmParams<f32, f32>
[src]
impl Fit<ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f32>, Dim<[usize; 2]>>, SvmResult> for SvmParams<f32, f32>
[src]impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, SvmResult> for SvmParams<f64, f64>
[src]
impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 1]>>, SvmResult> for SvmParams<f64, f64>
[src]impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, SvmResult> for SvmParams<f64, f64>
[src]
impl Fit<ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>, SvmResult> for SvmParams<f64, f64>
[src]impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&'_ ()>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, Pr>
[src]
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>
fn fit(
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, ArrayView2<'_, ()>>
) -> Result<Self::Object>
[src]
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, ArrayView2<'_, ()>>
) -> Result<Self::Object>
impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&'_ bool>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, Pr>
[src]
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>
fn fit(
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, ArrayView2<'_, bool>>
) -> Result<Self::Object>
[src]
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, ArrayView2<'_, bool>>
) -> Result<Self::Object>
impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&'_ bool>, Dim<[usize; 2]>>, SvmResult> for SvmParams<F, bool>
[src]
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>
fn fit(
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, ArrayView2<'_, bool>>
) -> Result<Self::Object>
[src]
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, ArrayView2<'_, bool>>
) -> Result<Self::Object>
impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, Pr>
[src]
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>
fn fit(
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, CountedTargets<bool, Array2<bool>>>
) -> Result<Self::Object>
[src]
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, CountedTargets<bool, Array2<bool>>>
) -> Result<Self::Object>
impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<OwnedRepr<bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, bool>
[src]
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>
fn fit(
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, CountedTargets<bool, Array2<bool>>>
) -> Result<Self::Object>
[src]
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, CountedTargets<bool, Array2<bool>>>
) -> Result<Self::Object>
impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<ViewRepr<&'_ bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, Pr>
[src]
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>
fn fit(
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, CountedTargets<bool, ArrayView2<'_, bool>>>
) -> Result<Self::Object>
[src]
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, CountedTargets<bool, ArrayView2<'_, bool>>>
) -> Result<Self::Object>
impl<F: Float> Fit<ArrayBase<ViewRepr<&'_ F>, Dim<[usize; 2]>>, CountedTargets<bool, ArrayBase<ViewRepr<&'_ bool>, Dim<[usize; 2]>>>, SvmResult> for SvmParams<F, bool>
[src]
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>
fn fit(
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, CountedTargets<bool, ArrayView2<'_, bool>>>
) -> Result<Self::Object>
[src]
&self,
dataset: &DatasetBase<ArrayView2<'_, F>, CountedTargets<bool, ArrayView2<'_, bool>>>
) -> Result<Self::Object>
impl Fit<ArrayBase<ViewRepr<&'_ f32>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&'_ f32>, Dim<[usize; 1]>>, SvmResult> for SvmParams<f32, f32>
[src]
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>
fn fit(
&self,
dataset: &DatasetBase<ArrayView2<'_, f32>, ArrayView1<'_, f32>>
) -> Result<Self::Object>
[src]
&self,
dataset: &DatasetBase<ArrayView2<'_, f32>, ArrayView1<'_, f32>>
) -> Result<Self::Object>
impl Fit<ArrayBase<ViewRepr<&'_ f32>, Dim<[usize; 2]>>, ArrayBase<ViewRepr<&'_ f32>, Dim<[usize; 2]>>, SvmResult> for SvmParams<f32, f32>
[src]
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>
fn fit(
&self,
dataset: &DatasetBase<ArrayView2<'_, f32>, ArrayView2<'_, f32>>
) -> Result<Self::Object>
[src]
&self,
dataset: &DatasetBase<ArrayView2<'_, f32>, ArrayView2<'_, f32>>
) -> Result<Self::Object>
Auto Trait Implementations
impl<F, T> RefUnwindSafe for SvmParams<F, T> where
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<F, T> RefUnwindSafe for SvmParams<F, T> where
F: RefUnwindSafe,
T: RefUnwindSafe,
impl<F, T> UnwindSafe for SvmParams<F, T> where
F: UnwindSafe,
T: UnwindSafe,
impl<F, T> UnwindSafe for SvmParams<F, T> where
F: UnwindSafe,
T: UnwindSafe,