Type Alias MultiTaskElasticNetParams

Source
pub type MultiTaskElasticNetParams<F> = ElasticNetParamsBase<F, true>;
Expand description

A hyper-parameter set for multi-task Elastic-Net

The multi-task version (Y becomes a measurement matrix) is also supported and solves the following objective function:

1 / (2 * n_samples) * || Y - XW ||^2_F
    + penalty * l1_ratio * ||W||_2,1
    + 0.5 * penalty * (1 - l1_ratio) * ||W||^2_F

See ElasticNetParams for information on parameters and return values.

§Example

use linfa_elasticnet::{MultiTaskElasticNetParams, ElasticNetError};
use linfa::prelude::*;
use ndarray::array;

let ds = Dataset::new(array![[1.0, 0.0], [0.0, 1.0]], array![[3.0, 1.1], [2.0, 2.2]]);

// create a new parameter set with penalty equals `1e-5`
let unchecked_params = MultiTaskElasticNetParams::new()
    .penalty(1e-5);

// fit model with unchecked parameter set
let model = unchecked_params.fit(&ds)?;

// transform into a verified parameter set
let checked_params = unchecked_params.check()?;

// Regenerate model with the verified parameters, this only returns
// errors originating from the fitting process
let model = checked_params.fit(&ds)?;

Aliased Type§

struct MultiTaskElasticNetParams<F>(/* private fields */);