Struct linfa_elasticnet::ElasticNetParamsBase
source · pub struct ElasticNetParamsBase<F, const MULTI_TASK: bool>(/* private fields */);
Implementations§
source§impl<F: Float, const MULTI_TASK: bool> ElasticNetParamsBase<F, MULTI_TASK>
impl<F: Float, const MULTI_TASK: bool> ElasticNetParamsBase<F, MULTI_TASK>
Configure and fit a Elastic Net model
sourcepub fn new() -> ElasticNetParamsBase<F, MULTI_TASK>
pub fn new() -> ElasticNetParamsBase<F, MULTI_TASK>
Create default elastic net hyper parameters
By default, an intercept will be fitted. To disable fitting an
intercept, call .with_intercept(false)
before calling .fit()
.
To additionally normalize the feature matrix before fitting, call
fit_intercept_and_normalize()
before calling fit()
. The feature
matrix will not be normalized by default.
sourcepub fn penalty(self, penalty: F) -> Self
pub fn penalty(self, penalty: F) -> Self
Set the overall parameter penalty parameter of the elastic net, otherwise known as alpha
.
Use l1_ratio
to configure how the penalty distributed to L1 and L2
regularization.
sourcepub fn l1_ratio(self, l1_ratio: F) -> Self
pub fn l1_ratio(self, l1_ratio: F) -> Self
Set l1_ratio parameter of the elastic net. Controls how the parameter
penalty is distributed to L1 and L2 regularization.
Setting l1_ratio
to 1.0 is equivalent to a “Lasso” penalization,
setting it to 0.0 is equivalent to “Ridge” penalization.
Defaults to 0.5
if not set
l1_ratio
must be between 0.0
and 1.0
.
sourcepub fn with_intercept(self, with_intercept: bool) -> Self
pub fn with_intercept(self, with_intercept: bool) -> Self
Configure the elastic net model to fit an intercept.
Defaults to true
if not set.
sourcepub fn tolerance(self, tolerance: F) -> Self
pub fn tolerance(self, tolerance: F) -> Self
Set the tolerance which is the minimum absolute change in any of the model parameters needed for the parameter optimization to continue.
Defaults to 1e-4
if not set
sourcepub fn max_iterations(self, max_iterations: u32) -> Self
pub fn max_iterations(self, max_iterations: u32) -> Self
Set the maximum number of iterations for the optimization routine.
Defaults to 1000
if not set
Trait Implementations§
source§impl<F: Clone, const MULTI_TASK: bool> Clone for ElasticNetParamsBase<F, MULTI_TASK>
impl<F: Clone, const MULTI_TASK: bool> Clone for ElasticNetParamsBase<F, MULTI_TASK>
source§fn clone(&self) -> ElasticNetParamsBase<F, MULTI_TASK>
fn clone(&self) -> ElasticNetParamsBase<F, MULTI_TASK>
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl<F: Float, const MULTI_TASK: bool> ParamGuard for ElasticNetParamsBase<F, MULTI_TASK>
impl<F: Float, const MULTI_TASK: bool> ParamGuard for ElasticNetParamsBase<F, MULTI_TASK>
§type Checked = ElasticNetValidParamsBase<F, MULTI_TASK>
type Checked = ElasticNetValidParamsBase<F, MULTI_TASK>
§type Error = ElasticNetError
type Error = ElasticNetError
source§fn check(self) -> Result<Self::Checked>
fn check(self) -> Result<Self::Checked>
source§fn check_unwrap(self) -> Self::Checkedwhere
Self: Sized,
fn check_unwrap(self) -> Self::Checkedwhere
Self: Sized,
check()
and unwraps the resultsource§impl<F: PartialEq, const MULTI_TASK: bool> PartialEq for ElasticNetParamsBase<F, MULTI_TASK>
impl<F: PartialEq, const MULTI_TASK: bool> PartialEq for ElasticNetParamsBase<F, MULTI_TASK>
source§fn eq(&self, other: &ElasticNetParamsBase<F, MULTI_TASK>) -> bool
fn eq(&self, other: &ElasticNetParamsBase<F, MULTI_TASK>) -> bool
self
and other
values to be equal, and is used
by ==
.