himalaya.lasso.SparseGroupLassoCV

class himalaya.lasso.SparseGroupLassoCV(groups=None, l1_regs=[0], l21_regs=[0], solver='proximal_gradient', solver_params=None, cv=5, force_cpu=False)[source]

Sparse group Lasso

Solved with hyperparameter grid-search over cross-validation.

Parameters
groupsarray of shape (n_features, ) or None

Encoding of the group of each feature. If None, all features are gathered in one group, and the problem is equivalent to the Lasso.

l21_regsarray of shape (n_l21_regs, )

All the Group Lasso regularization parameter tested.

l1_regsarray of shape (n_l1_regs, )

All the Lasso regularization parameter tested.

solverstr

Algorithm used during the fit, “proximal_gradient” only for now.

solver_paramsdict or None

Additional parameters for the solver. See more details in the docstring of the function: SparseGroupLassoCV.ALL_SOLVERS[solver]

cvint or scikit-learn splitter

Cross-validation splitter. If an int, KFold is used.

force_cpubool

If True, computations will be performed on CPU, ignoring the current backend. If False, use the current backend.

Examples

>>> from himalaya.lasso import SparseGroupLassoCV
>>> import numpy as np
>>> n_samples, n_features, n_targets = 10, 5, 3
>>> X = np.random.randn(n_samples, n_features)
>>> Y = np.random.randn(n_samples, n_targets)
>>> clf = SparseGroupLassoCV()
>>> clf.fit(X, Y)
SparseGroupLassoCV()
Attributes
coef_array of shape (n_samples) or (n_samples, n_targets)

Coefficient of the linear model. Always on CPU.

best_l21_reg_array of shape (n_targets, )

Best hyperparameter per target.

best_l1_reg_array of shape (n_targets, )

Best hyperparameter per target.

cv_scores_array of shape (n_l21_regs * n_l1_regs, n_targets)

Cross-validation scores of all tested hyperparameters. The scores are computed with r2_score.

n_features_in_int

Number of features used during the fit.

Methods

fit(X, y)

Fit the model

get_params([deep])

Get parameters for this estimator.

predict(X)

Predict using the model.

score(X, y)

Return the coefficient of determination R^2 of the prediction.

set_params(**params)

Set the parameters of this estimator.