celer.ElasticNetCV#

class celer.ElasticNetCV(l1_ratio=1.0, eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, max_iter=100, tol=0.0001, cv=None, verbose=0, max_epochs=50000, p0=10, prune=True, precompute='auto', positive=False, n_jobs=None)[source]#

ElasticNetCV scikit-learn estimator based on Celer solver

The best model is selected by cross-validation.

The optimization objective for ElasticNet is:

1 / (2 * n_samples) * ||y - X w||^2_2
+ alpha * l1_ratio * \sum_j weights_j |w_j|
+ 0.5 * alpha * (1 - l1_ratio) * \sum_j weights_j |w_j|^2)
Parameters:
l1_ratiofloat or list of float, optional

The ElasticNet mixing parameter, with 0 < l1_ratio <= 1. Defaults to 1.0 which corresponds to L1 penalty (Lasso). l1_ratio = 0 (Ridge regression) is not supported. This parameter can be a list, in which case the different values are tested by cross-validation and the one giving the best prediction score is used. Note that a good choice of list of values for l1_ratio is often to put more values close to 1 (i.e. Lasso) and less close to 0 (i.e. Ridge), as in [.1, .5, .7, .9, .95, .99, 1].

epsfloat, optional

Length of the path. eps=1e-3 means that alpha_min / alpha_max = 1e-3.

n_alphasint, optional

Number of alphas along the regularization path.

alphasnumpy array, optional

List of alphas where to compute the models If None alphas are set automatically.

fit_interceptboolean, default True

whether to calculate the intercept for this model. If set to false, no intercept will be used in calculations (e.g. data is expected to be already centered).

max_iterint, optional

The maximum number of iterations (subproblem definitions).

tolfloat, optional

Stopping criterion for the optimization: the solver runs until the duality gap is smaller than tol * norm(y) ** 2 / len(y) or the maximum number of iteration is reached.

cvint, cross-validation generator or an iterable, optional

Determines the cross-validation splitting strategy. Possible inputs for cv are: - None, to use the default 3-fold cross-validation, - integer, to specify the number of folds. - An object to be used as a cross-validation generator. - An iterable yielding train/test splits. For integer/None inputs, sklearn KFold is used.

verbosebool or integer

Amount of verbosity.

max_epochsint, optional (default=50000)

Maximum number of coordinate descent epochs when solving a subproblem.

p0int, optional (default=10)

Number of features in the first working set.

prunebool, optional (default=False)

Whether to use pruning when growing the working sets.

precomputeignored parameter, kept for sklearn compatibility.
positivebool, optional (default=False)

When set to True, forces the coefficients to be positive.

n_jobsint or None, optional (default=None)

Number of CPUs to use during the cross validation. None means 1 unless in a joblib.parallel_backend context. -1 means using all processors.

See also

celer_path
Lasso
Attributes:
alpha_float

The amount of penalization chosen by cross validation.

l1_ratio_float

The compromise between l1 and l2 penalization chosen by cross validation.

coef_array, shape (n_features,)

parameter vector (w in the cost function formula).

intercept_float

independent term in decision function.

mse_path_array, shape (n_alphas, n_folds)

mean square error for the test set on each fold, varying alpha.

alphas_numpy array, shape (n_alphas,)

The grid of alphas used for fitting.

dual_gap_ndarray, shape ()

The dual gap at the end of the optimization for the optimal alpha (alpha_).

n_iter_int

number of iterations run by the coordinate descent solver to reach the specified tolerance for the optimal alpha.

__init__(l1_ratio=1.0, eps=0.001, n_alphas=100, alphas=None, fit_intercept=True, max_iter=100, tol=0.0001, cv=None, verbose=0, max_epochs=50000, p0=10, prune=True, precompute='auto', positive=False, n_jobs=None)[source]#

Methods

__init__([l1_ratio, eps, n_alphas, alphas, ...])

fit(X, y[, sample_weight])

Fit linear model with coordinate descent.

get_params([deep])

Get parameters for this estimator.

path(X, y, alphas[, coef_init])

Compute Lasso path with Celer.

predict(X)

Predict using the linear model.

score(X, y[, sample_weight])

Return the coefficient of determination of the prediction.

set_params(**params)

Set the parameters of this estimator.