pub struct PoissonRegressor<F> {
pub alpha: F,
pub max_iter: usize,
pub tol: F,
pub fit_intercept: bool,
pub solver: Solver,
pub warm_start: bool,
pub coef_init: Option<(Array1<F>, F)>,
}Expand description
Poisson regressor — GLM with Poisson family and log link.
Suitable for modelling count data (y >= 0, integer-valued).
§Type Parameters
F: The floating-point type (f32orf64).
Fields§
§alpha: FL2 regularization strength.
max_iter: usizeMaximum number of IRLS iterations.
tol: FConvergence tolerance.
fit_intercept: boolWhether to fit an intercept.
solver: SolverOptimization algorithm requested, mirroring sklearn’s solver parameter
(glm.py:140-145, default "lbfgs").
ferrolearn fits via IRLS regardless of this value (R-DEV-7); the parameter
is accepted for sklearn API parity (R-DEV-2) and the observable
coef_ / intercept_ match sklearn for either value. See Solver.
warm_start: boolWhether to warm-start from an explicit initial point, mirroring sklearn’s
warm_start parameter (default false, glm.py:146, :576). See
GLMRegressor::warm_start for the R-DEV-2 / R-DEV-7 rationale.
coef_init: Option<(Array1<F>, F)>Explicit warm-start initial point (feature_coefficients, intercept) — the
ferrolearn analog of sklearn reusing self.coef_ / self.intercept_
(R-DEV-7, glm.py:244-250). Consulted only when warm_start is true. Set
via PoissonRegressor::with_coef_init.
Implementations§
Source§impl<F: Float + FromPrimitive> PoissonRegressor<F>
impl<F: Float + FromPrimitive> PoissonRegressor<F>
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new PoissonRegressor with default settings.
Defaults: alpha = 1.0, max_iter = 100, tol = 1e-4,
fit_intercept = true, solver = Solver::Lbfgs (sklearn default).
Sourcepub fn with_alpha(self, alpha: F) -> Self
pub fn with_alpha(self, alpha: F) -> Self
Set the L2 regularization strength.
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 IRLS 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.
Sourcepub fn with_solver(self, solver: Solver) -> Self
pub fn with_solver(self, solver: Solver) -> Self
Set the optimization Solver, mirroring sklearn’s solver parameter
(glm.py:140-145, default "lbfgs").
ferrolearn fits via IRLS regardless of the value (R-DEV-7); both values
produce the same observable coef_ / intercept_ (sklearn API parity,
R-DEV-2).
Sourcepub fn with_warm_start(self, warm_start: bool) -> Self
pub fn with_warm_start(self, warm_start: bool) -> Self
Enable or disable warm-starting, mirroring sklearn’s warm_start
parameter (default false, glm.py:146, :576). See
GLMRegressor::with_warm_start for the R-DEV-2 / R-DEV-7 rationale; the
warm-start point is supplied explicitly via
PoissonRegressor::with_coef_init.
Sourcepub fn with_coef_init(self, coef: Array1<F>, intercept: F) -> Self
pub fn with_coef_init(self, coef: Array1<F>, intercept: F) -> Self
Set the explicit warm-start initial point (feature_coefficients, intercept) — the ferrolearn analog of sklearn reusing self.coef_ /
self.intercept_ (R-DEV-7, glm.py:244-250). Only consulted when
warm_start is true; coef’s length must equal the number of features.
Source§impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> PoissonRegressor<F>
impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> PoissonRegressor<F>
Sourcepub fn fit_with_sample_weight(
&self,
x: &Array2<F>,
y: &Array1<F>,
sample_weight: &Array1<F>,
) -> Result<FittedGLMRegressor<F>, FerroError>
pub fn fit_with_sample_weight( &self, x: &Array2<F>, y: &Array1<F>, sample_weight: &Array1<F>, ) -> Result<FittedGLMRegressor<F>, FerroError>
Fit the Poisson GLM via IRLS with per-sample weights sample_weight.
Mirrors sklearn’s PoissonRegressor.fit(X, y, sample_weight)
(glm.py:170, :229-242). See
GLMRegressor::fit_with_sample_weight for the weighting semantics;
an all-ones weight vector reproduces Fit::fit exactly.
§Errors
Trait Implementations§
Source§impl<F: Clone> Clone for PoissonRegressor<F>
impl<F: Clone> Clone for PoissonRegressor<F>
Source§fn clone(&self) -> PoissonRegressor<F>
fn clone(&self) -> PoissonRegressor<F>
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: Debug> Debug for PoissonRegressor<F>
impl<F: Debug> Debug for PoissonRegressor<F>
Source§impl<F: Float + FromPrimitive> Default for PoissonRegressor<F>
impl<F: Float + FromPrimitive> Default for PoissonRegressor<F>
Source§impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for PoissonRegressor<F>
impl<F: Float + Send + Sync + ScalarOperand + FromPrimitive + 'static> Fit<ArrayBase<OwnedRepr<F>, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for PoissonRegressor<F>
Source§fn fit(
&self,
x: &Array2<F>,
y: &Array1<F>,
) -> Result<FittedGLMRegressor<F>, FerroError>
fn fit( &self, x: &Array2<F>, y: &Array1<F>, ) -> Result<FittedGLMRegressor<F>, FerroError>
Source§type Fitted = FittedGLMRegressor<F>
type Fitted = FittedGLMRegressor<F>
fit.Source§type Error = FerroError
type Error = FerroError
fit.Source§impl<F> PipelineEstimator<F> for PoissonRegressor<F>
impl<F> PipelineEstimator<F> for PoissonRegressor<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 PoissonRegressor<F>where
F: Freeze,
impl<F> RefUnwindSafe for PoissonRegressor<F>where
F: RefUnwindSafe,
impl<F> Send for PoissonRegressor<F>where
F: Send,
impl<F> Sync for PoissonRegressor<F>where
F: Sync,
impl<F> Unpin for PoissonRegressor<F>where
F: Unpin,
impl<F> UnsafeUnpin for PoissonRegressor<F>where
F: UnsafeUnpin,
impl<F> UnwindSafe for PoissonRegressor<F>where
F: UnwindSafe + RefUnwindSafe,
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