pub struct LinearSVC<F> {
pub c: F,
pub max_iter: usize,
pub tol: F,
pub loss: LinearSVCLoss,
}Expand description
Linear Support Vector Classifier (primal formulation).
Solves the L2-regularized hinge or squared-hinge loss via coordinate descent in the primal. Supports binary and multiclass (one-vs-rest) classification.
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§c: FInverse regularization strength. Larger values allow more misclassification.
max_iter: usizeMaximum number of coordinate descent iterations.
tol: FConvergence tolerance on the change in weight vector.
loss: LinearSVCLossLoss function to use.
Implementations§
Source§impl<F: Float> LinearSVC<F>
impl<F: Float> LinearSVC<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new LinearSVC with default settings.
Defaults: C = 1.0, max_iter = 1000, tol = 1e-4,
loss = SquaredHinge.
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 iterations.
Sourcepub fn with_loss(self, loss: LinearSVCLoss) -> Self
pub fn with_loss(self, loss: LinearSVCLoss) -> Self
Set the loss function.
Trait Implementations§
Source§impl<F: Float + Send + Sync + ScalarOperand + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>> for LinearSVC<F>
impl<F: Float + Send + Sync + ScalarOperand + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>> for LinearSVC<F>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array1<usize>,
) -> Result<FittedLinearSVC<F>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array1<usize>, ) -> Result<FittedLinearSVC<F>, FerroError>
Fit the linear SVC model using coordinate descent.
§Errors
FerroError::ShapeMismatch— sample count mismatch.FerroError::InvalidParameter—Cnot positive.FerroError::InsufficientSamples— fewer than 2 distinct classes.
Source§type Fitted = FittedLinearSVC<F>
type Fitted = FittedLinearSVC<F>
The fitted model type returned by
fit.Source§type Error = FerroError
type Error = FerroError
The error type returned by
fit.Auto Trait Implementations§
impl<F> Freeze for LinearSVC<F>where
F: Freeze,
impl<F> RefUnwindSafe for LinearSVC<F>where
F: RefUnwindSafe,
impl<F> Send for LinearSVC<F>where
F: Send,
impl<F> Sync for LinearSVC<F>where
F: Sync,
impl<F> Unpin for LinearSVC<F>where
F: Unpin,
impl<F> UnsafeUnpin for LinearSVC<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for LinearSVC<F>where
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