Expand description
Multi-task Lasso regression (joint multi-output L21 block coordinate descent).
This module provides MultiTaskLasso, the multi-output linear model that
fits all target columns jointly under an L2,1 (group-Lasso) penalty,
minimizing
(1 / (2 * n_samples)) * ||Y - X W||_F^2 + alpha * ||W||_21where ||W||_21 = sum_j sqrt(sum_k W[j,k]^2) is the sum over features of the
L2 norm of each feature’s coefficient ROW across tasks. The mixed L2,1 norm
couples a feature’s coefficients across all tasks: a feature is either active
for ALL tasks (a non-zero row) or inactive for all of them (an all-zero row),
so MultiTaskLasso performs joint feature selection across outputs.
Mirrors sklearn.linear_model.MultiTaskLasso
(sklearn/linear_model/_coordinate_descent.py:2663, class MultiTaskLasso(MultiTaskElasticNet)); the production solver is the Cython
enet_coordinate_descent_multi_task in _cd_fast.pyx:740 (objective at
:756, 0.5 * norm(Y - X W.T)^2 + l1_reg ||W.T||_21 + 0.5 * l2_reg norm(W.T)^2). MultiTaskLasso is MultiTaskElasticNet(l1_ratio=1.0), i.e.
l2_reg = 0, l1_reg = alpha * n_samples. ferrolearn implements the dense
block-coordinate-descent core directly.
§REQ status (per .design/linear/lasso.md, mirrors sklearn/linear_model/_coordinate_descent.py @ 1.5.2)
| REQ | Status | Evidence |
|---|---|---|
| REQ-13 (MultiTaskLasso, multi-output L21 block CD) | SHIPPED | MultiTaskLasso<F> / FittedMultiTaskLasso<F> in this module: impl Fit<Array2<F>, Array2<F>> runs block coordinate descent porting _cd_fast.pyx::enet_coordinate_descent_multi_task (:740-959, l2_reg=0): l1_reg = alpha*n, per-feature block update `W[j,:] = tmp * max(1 - l1_reg/ |
§Examples
use ferrolearn_linear::MultiTaskLasso;
use ferrolearn_core::{Fit, Predict};
use ndarray::{array, Array2};
let model = MultiTaskLasso::<f64>::new().with_alpha(0.3);
let x: Array2<f64> = array![[1.0, 2.0], [2.0, 1.0], [3.0, 4.0], [4.0, 3.0], [5.0, 5.0]];
let y: Array2<f64> = array![[3.0, 1.0], [2.5, 2.0], [7.1, 3.5], [6.0, 4.2], [11.2, 6.0]];
let fitted = model.fit(&x, &y).unwrap();
let preds = fitted.predict(&x).unwrap();Structs§
- Fitted
Multi Task Lasso - Fitted multi-task Lasso regression model.
- Multi
Task Lasso - Multi-task Lasso regression (joint multi-output L2,1-regularized least squares).