Struct linfa_elasticnet::ElasticNet
source · [−]pub struct ElasticNet<F> { /* private fields */ }
Expand description
Elastic Net model
This struct contains the parameters of a fitted elastic net model. This includes the seperating hyperplane, (optionally) intercept, duality gaps and the number of step needed in the computation.
Model implementation
The coordinate descent algorithm is used to solve the lasso and ridge problem. It optimizes each parameter seperately, holding all the others fixed. This cycles as long as the coefficients have not stabilized or the maximum number of iterations is reached.
See also:
Implementations
sourceimpl<F: Float> ElasticNet<F>
impl<F: Float> ElasticNet<F>
View the fitted parameters and make predictions with a fitted elastic net model
sourcepub fn hyperplane(&self) -> &Array1<F>
pub fn hyperplane(&self) -> &Array1<F>
Get the fitted hyperplane
sourcepub fn duality_gap(&self) -> F
pub fn duality_gap(&self) -> F
Get the duality gap at the end of the optimization algorithm
sourceimpl<F: Float> ElasticNet<F>
impl<F: Float> ElasticNet<F>
sourcepub fn params() -> ElasticNetParams<F>
pub fn params() -> ElasticNetParams<F>
Create a default parameter set for construction of ElasticNet model
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 ridge() -> ElasticNetParams<F>
pub fn ridge() -> ElasticNetParams<F>
Create a ridge only model
sourcepub fn lasso() -> ElasticNetParams<F>
pub fn lasso() -> ElasticNetParams<F>
Create a LASSO only model
Trait Implementations
sourceimpl<F: Clone> Clone for ElasticNet<F>
impl<F: Clone> Clone for ElasticNet<F>
sourcefn clone(&self) -> ElasticNet<F>
fn clone(&self) -> ElasticNet<F>
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl<F: Debug> Debug for ElasticNet<F>
impl<F: Debug> Debug for ElasticNet<F>
sourceimpl<F: Float, D: Data<Elem = F>> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for ElasticNet<F>
impl<F: Float, D: Data<Elem = F>> PredictInplace<ArrayBase<D, Dim<[usize; 2]>>, ArrayBase<OwnedRepr<F>, Dim<[usize; 1]>>> for ElasticNet<F>
sourcefn predict_inplace(&self, x: &ArrayBase<D, Ix2>, y: &mut Array1<F>)
fn predict_inplace(&self, x: &ArrayBase<D, Ix2>, y: &mut Array1<F>)
Given an input matrix X
, with shape (n_samples, n_features)
,
predict
returns the target variable according to elastic net
learned from the training data distribution.
sourcefn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array1<F>
fn default_target(&self, x: &ArrayBase<D, Ix2>) -> Array1<F>
Create targets that predict_inplace
works with.
Auto Trait Implementations
impl<F> RefUnwindSafe for ElasticNet<F> where
F: RefUnwindSafe,
impl<F> Send for ElasticNet<F> where
F: Send,
impl<F> Sync for ElasticNet<F> where
F: Sync,
impl<F> Unpin for ElasticNet<F> where
F: Unpin,
impl<F> UnwindSafe for ElasticNet<F> where
F: UnwindSafe + RefUnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more