== 'random'. Pass an int for reproducible output across multiple function calls. See :term:`Glossary `. selection : {'cyclic', 'random'}, default='cyclic' If set to 'random', a random coefficient is updated every iteration rather than looping over features sequentially by default. This (setting to 'random') often leads to significantly faster convergence especially when tol is higher than 1e-4. Attributes ---------- coef_ : ndarray of shape (n_features,) or (n_targets, n_features) Parameter vector (w in the cost function formula). sparse_coef_ : sparse matrix of shape (n_features,) or (n_targets, n_features) Sparse representation of the `coef_`. intercept_ : float or ndarray of shape (n_targets,) Independent term in decision function. n_iter_ : list of int Number of iterations run by the coordinate descent solver to reach the specified tolerance. dual_gap_ : float or ndarray of shape (n_targets,) Given param alpha, the dual gaps at the end of the optimization, same shape as each observation of y. n_features_in_ : int Number of features seen during :term:`fit`. .. versionadded:: 0.24 feature_names_in_ : ndarray of shape (`n_features_in_`,) Names of features seen during :term:`fit`. Defined only when `X` has feature names that are all strings. .. versionadded:: 1.0 See Also -------- ElasticNetCV : Elastic net model with best model selection by cross-validation. SGDRegressor : Implements elastic net regression with incremental training. SGDClassifier : Implements logistic regression with elastic net penalty (``SGDClassifier(loss="log_loss", penalty="elasticnet")``). Notes ----- To avoid unnecessary memory duplication the X argument of the fit method should be directly passed as a Fortran-contiguous numpy array. The precise stopping criteria based on `tol` are the following: First, check that that maximum coordinate update, i.e. :math:`\max_j |w_j^{new} - w_j^{old}|` is smaller than `tol` times the maximum absolute coefficient, :math:`\max_j |w_j|`. If so, then additionally check whether the dual gap is smaller than `tol` times :math:`||y||_2^2 / n_{ ext{samples}}`. Examples -------- >>> from sklearn.linear_model import ElasticNet >>> from sklearn.datasets import make_regression >>> X, y = make_regression(n_features=2, random_state=0) >>> regr = ElasticNet(random_state=0) >>> regr.fit(X, y) ElasticNet(random_state=0) >>> print(regr.coef_) [18.83816048 64.55968825] >>> print(regr.intercept_) 1.451... >>> print(regr.predict([[0, 0]])) [1.451...] rG