pub struct SVC<F, K> {
pub kernel: K,
pub c: F,
pub tol: F,
pub max_iter: usize,
pub cache_size: usize,
}Expand description
Support Vector Classifier.
Uses Sequential Minimal Optimization (SMO) to solve the dual QP. Supports multiclass via one-vs-one strategy.
§Type Parameters
F: The floating-point type (f32orf64).K: The kernel type (e.g.,LinearKernel,RbfKernel).
Fields§
§kernel: KThe kernel function.
c: FRegularization parameter (penalty for misclassification).
tol: FConvergence tolerance.
max_iter: usizeMaximum number of SMO iterations.
cache_size: usizeSize of the kernel evaluation LRU cache.
Implementations§
Source§impl<F: Float, K: Kernel<F>> SVC<F, K>
impl<F: Float, K: Kernel<F>> SVC<F, K>
Sourcepub fn new(kernel: K) -> Self
pub fn new(kernel: K) -> Self
Create a new SVC with the given kernel and default hyperparameters.
Defaults: C = 1.0, tol = 1e-3, max_iter = 10000, cache_size = 1024.
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.
Trait Implementations§
Source§impl<F: Float + Send + Sync + ScalarOperand + 'static, K: Kernel<F> + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>> for SVC<F, K>
impl<F: Float + Send + Sync + ScalarOperand + 'static, K: Kernel<F> + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>> for SVC<F, K>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array1<usize>,
) -> Result<FittedSVC<F, K>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array1<usize>, ) -> Result<FittedSVC<F, K>, FerroError>
Fit the SVC model using SMO.
§Errors
Returns FerroError::ShapeMismatch if x and y have different
sample counts.
Returns FerroError::InvalidParameter if C is not positive.
Returns FerroError::InsufficientSamples if fewer than 2 classes.
Source§type Error = FerroError
type Error = FerroError
The error type returned by
fit.Auto Trait Implementations§
impl<F, K> Freeze for SVC<F, K>
impl<F, K> RefUnwindSafe for SVC<F, K>where
K: RefUnwindSafe,
F: RefUnwindSafe,
impl<F, K> Send for SVC<F, K>
impl<F, K> Sync for SVC<F, K>
impl<F, K> Unpin for SVC<F, K>
impl<F, K> UnsafeUnpin for SVC<F, K>where
K: UnsafeUnpin,
F: UnsafeUnpin,
impl<F, K> UnwindSafe for SVC<F, K>where
K: UnwindSafe,
F: 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
Mutably borrows from an owned value. Read more
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,
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>
Converts
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>
Converts
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