pub struct LogisticRegression<F> {
pub c: F,
pub max_iter: usize,
pub tol: F,
pub fit_intercept: bool,
}Expand description
Logistic regression classifier.
Uses L-BFGS optimization to minimize the regularized logistic loss. Supports both binary and multiclass (multinomial) classification.
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§c: FInverse regularization strength. Smaller values specify stronger regularization (matching scikit-learn’s convention).
max_iter: usizeMaximum number of L-BFGS iterations.
tol: FConvergence tolerance for the optimizer.
fit_intercept: boolWhether to fit an intercept (bias) term.
Implementations§
Source§impl<F: Float> LogisticRegression<F>
impl<F: Float> LogisticRegression<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new LogisticRegression with default settings.
Defaults: C = 1.0, max_iter = 1000, tol = 1e-4,
fit_intercept = true.
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_fit_intercept(self, fit_intercept: bool) -> Self
pub fn with_fit_intercept(self, fit_intercept: bool) -> Self
Set whether to fit an intercept term.
Trait Implementations§
Source§impl<F: Clone> Clone for LogisticRegression<F>
impl<F: Clone> Clone for LogisticRegression<F>
Source§fn clone(&self) -> LogisticRegression<F>
fn clone(&self) -> LogisticRegression<F>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<F: Debug> Debug for LogisticRegression<F>
impl<F: Debug> Debug for LogisticRegression<F>
Source§impl<F: Float> Default for LogisticRegression<F>
impl<F: Float> Default for LogisticRegression<F>
Source§impl<F: Float + Send + Sync + ScalarOperand + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>> for LogisticRegression<F>
impl<F: Float + Send + Sync + ScalarOperand + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<usize>, Dim<[usize; 1]>>> for LogisticRegression<F>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array1<usize>,
) -> Result<FittedLogisticRegression<F>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array1<usize>, ) -> Result<FittedLogisticRegression<F>, FerroError>
Fit the logistic regression model using L-BFGS optimization.
§Errors
Returns FerroError::ShapeMismatch if the number of samples in
x and y differ.
Returns FerroError::InvalidParameter if C is not positive.
Returns FerroError::InsufficientSamples if there are fewer
than 2 distinct classes.
Source§type Fitted = FittedLogisticRegression<F>
type Fitted = FittedLogisticRegression<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Source§impl<F> PipelineEstimator<F> for LogisticRegression<F>
impl<F> PipelineEstimator<F> for LogisticRegression<F>
Source§fn fit_pipeline(
&self,
x: &Array2<F>,
y: &Array1<F>,
) -> Result<Box<dyn FittedPipelineEstimator<F>>, FerroError>
fn fit_pipeline( &self, x: &Array2<F>, y: &Array1<F>, ) -> Result<Box<dyn FittedPipelineEstimator<F>>, FerroError>
Auto Trait Implementations§
impl<F> Freeze for LogisticRegression<F>where
F: Freeze,
impl<F> RefUnwindSafe for LogisticRegression<F>where
F: RefUnwindSafe,
impl<F> Send for LogisticRegression<F>where
F: Send,
impl<F> Sync for LogisticRegression<F>where
F: Sync,
impl<F> Unpin for LogisticRegression<F>where
F: Unpin,
impl<F> UnsafeUnpin for LogisticRegression<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for LogisticRegression<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
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>
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