Struct linfa_svm::hyperparams::SvmParams
source · pub struct SvmParams<F: Float, T>(/* private fields */);
Implementations§
source§impl<F: Float, T> SvmParams<F, T>
impl<F: Float, T> SvmParams<F, T>
sourcepub fn new() -> Self
pub fn new() -> Self
Create hyper parameter set
This creates a SvmParams
and sets it to the default values:
- C values of (1, 1)
- Eps of 1e-7
- No shrinking
- Linear kernel
sourcepub fn eps(self, new_eps: F) -> Self
pub fn eps(self, new_eps: F) -> Self
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.
sourcepub fn shrinking(self, shrinking: bool) -> Self
pub fn shrinking(self, shrinking: bool) -> Self
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.
sourcepub fn with_kernel_params(self, kernel: KernelParams<F>) -> Self
pub fn with_kernel_params(self, kernel: KernelParams<F>) -> Self
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.
sourcepub fn with_platt_params(self, platt: PlattParams<F, ()>) -> Self
pub fn with_platt_params(self, platt: PlattParams<F, ()>) -> Self
Set the platt params for probability calibration
sourcepub fn gaussian_kernel(self, eps: F) -> Self
pub fn gaussian_kernel(self, eps: F) -> Self
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)
sourcepub fn polynomial_kernel(self, constant: F, degree: F) -> Self
pub fn polynomial_kernel(self, constant: F, degree: F) -> Self
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)
sourcepub fn linear_kernel(self) -> Self
pub fn linear_kernel(self) -> Self
Sets the model to use the Linear kernel. For this kernel the
distance between two points is computed as : d(x, x') = <x, x'>
Trait Implementations§
source§impl<F: Float, L> ParamGuard for SvmParams<F, L>
impl<F: Float, L> ParamGuard for SvmParams<F, L>
§type Checked = SvmValidParams<F, L>
type Checked = SvmValidParams<F, L>
source§fn check_ref(&self) -> Result<&Self::Checked, Self::Error>
fn check_ref(&self) -> Result<&Self::Checked, Self::Error>
source§fn check(self) -> Result<Self::Checked, Self::Error>
fn check(self) -> Result<Self::Checked, Self::Error>
source§fn check_unwrap(self) -> Self::Checkedwhere
Self: Sized,
fn check_unwrap(self) -> Self::Checkedwhere Self: Sized,
check()
and unwraps the result