pub struct OneClassSVM<F, K> {
pub nu: F,
pub kernel: K,
pub tol: F,
pub max_iter: usize,
pub cache_size: usize,
pub shrinking: bool,
}Expand description
Fields§
§nu: FThe nu parameter: upper bound on the fraction of outliers.
Must be in (0, 1]. Default: 0.5.
kernel: KThe kernel function.
tol: FConvergence tolerance.
max_iter: usizeMaximum number of SMO iterations. 0 is the sklearn max_iter=-1
sentinel (“no iteration limit”; libsvm runs to convergence) — the SMO
loop then runs until the KKT gap closes; a non-zero value caps the
iteration count (sklearn/svm/_classes.py:1721, max_iter default -1).
cache_size: usizeSize of the kernel evaluation cache (sklearn cache_size, default
200). Accepted for API parity; this module has no kernel cache.
shrinking: boolWhether to use libsvm’s shrinking heuristic (sklearn shrinking,
_classes.py:1718, default true).
Accepted for API parity. The one-class optimum is shrinking-invariant
and ferrolearn’s SMO implements no shrinking heuristic, so this flag
DOES NOT alter the fitted α/dual_coef_/intercept_ (R-DEV-7).
Implementations§
Source§impl<F: Float, K: Kernel<F>> OneClassSVM<F, K>
impl<F: Float, K: Kernel<F>> OneClassSVM<F, K>
Sourcepub fn new(kernel: K) -> Self
pub fn new(kernel: K) -> Self
Create a new OneClassSVM with the given kernel and default hyperparameters.
Defaults: nu = 0.5, tol = 1e-3, max_iter = 0 (= sklearn -1, no
iteration limit — runs to convergence), cache_size = 200,
shrinking = true (sklearn/svm/_classes.py:1712-1721).
Sourcepub fn with_max_iter(self, max_iter: usize) -> Self
pub fn with_max_iter(self, max_iter: usize) -> Self
Set the maximum number of SMO iterations.
Sourcepub fn with_cache_size(self, cache_size: usize) -> Self
pub fn with_cache_size(self, cache_size: usize) -> Self
Set the kernel cache size.
Sourcepub fn with_shrinking(self, shrinking: bool) -> Self
pub fn with_shrinking(self, shrinking: bool) -> Self
Set the shrinking flag (sklearn shrinking, default true).
Accepted for API parity; the one-class optimum is shrinking-invariant (ferrolearn’s SMO has no shrinking heuristic — R-DEV-7), so this does not change the fit.
Trait Implementations§
Source§impl<F: Clone, K: Clone> Clone for OneClassSVM<F, K>
impl<F: Clone, K: Clone> Clone for OneClassSVM<F, K>
Source§fn clone(&self) -> OneClassSVM<F, K>
fn clone(&self) -> OneClassSVM<F, K>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F: Float + Send + Sync + ScalarOperand + 'static, K: Kernel<F> + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for OneClassSVM<F, K>
impl<F: Float + Send + Sync + ScalarOperand + 'static, K: Kernel<F> + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ()> for OneClassSVM<F, K>
Source§fn fit(
&self,
x: &Array2<F>,
_y: &(),
) -> Result<FittedOneClassSVM<F, K>, FerroError>
fn fit( &self, x: &Array2<F>, _y: &(), ) -> Result<FittedOneClassSVM<F, K>, FerroError>
Fit the One-Class SVM.
§Errors
FerroError::InvalidParameterifnuis not in(0, 1].FerroError::InsufficientSamplesif no training data is provided.
Source§type Fitted = FittedOneClassSVM<F, K>
type Fitted = FittedOneClassSVM<F, K>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Auto Trait Implementations§
impl<F, K> Freeze for OneClassSVM<F, K>
impl<F, K> RefUnwindSafe for OneClassSVM<F, K>where
F: RefUnwindSafe,
K: RefUnwindSafe,
impl<F, K> Send for OneClassSVM<F, K>
impl<F, K> Sync for OneClassSVM<F, K>
impl<F, K> Unpin for OneClassSVM<F, K>
impl<F, K> UnsafeUnpin for OneClassSVM<F, K>where
F: UnsafeUnpin,
K: UnsafeUnpin,
impl<F, K> UnwindSafe for OneClassSVM<F, K>where
F: UnwindSafe,
K: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T, U> Imply<T> for U
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more