# ElasticNet

### *class* cuml.dask.linear_model.ElasticNet(, client=None, \*\*kwargs)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/linear_model/elastic_net.py#L10)

ElasticNet extends LinearRegression with combined L1 and L2 regularizations
on the coefficients when predicting response y with a linear combination of
the predictors in X. It can reduce the variance of the predictors, force
some coefficients to be small, and improves the conditioning of the
problem.

cuML’s ElasticNet an array-like object or cuDF DataFrame, uses coordinate
descent to fit a linear model.

* **Parameters:**
  **alpha**
  : Constant that multiplies the L1 term.
    alpha = 0 is equivalent to an ordinary least square, solved by the
    LinearRegression object.
    For numerical reasons, using alpha = 0 with the Lasso object is not
    advised.
    Given this, you should use the LinearRegression object.

  **l1_ratio: float (default = 0.5)**
  : The ElasticNet mixing parameter, with 0 <= l1_ratio <= 1.
    For l1_ratio = 0 the penalty is an L2 penalty. For l1_ratio = 1 it is
    an L1 penalty.
    For 0 < l1_ratio < 1, the penalty is a combination of L1 and L2.

  **fit_intercept**
  : If True, Lasso tries to correct for the global mean of y.
    If False, the model expects that you have centered the data.

  **max_iter**
  : The maximum number of iterations

  **tol**
  : The tolerance for the optimization: if the updates are smaller than
    tol, the optimization code checks the dual gap for optimality and
    continues until it is smaller than tol.

  **selection**
  : 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.

  **output_type**
  : Return results and set estimator attributes to the indicated output
    type. If None, the output type set at the module level
    (`cuml.global_settings.output_type`) will be used. See
    [Output Data Type Configuration](../../cuml/index.html.md#output-data-type-configuration) for more info.
* **Attributes:**
  **coef_**
  : The estimated coefficients for the linear regression model.

  **intercept_**
  : The independent term. If `fit_intercept` is False, will be 0.

  **n_iter_**
  : The number of iterations taken by the solver.

  **For additional docs, see \`scikitlearn’s ElasticNet**

  **<https://scikit-learn.org/stable/modules/generated/sklearn.linear_model.ElasticNet.html>\`_.**

### Methods

| [`fit`](#cuml.dask.linear_model.ElasticNet.fit)(X, y)             | Fit the model with X and y.   |
|------------------------------------------------------------------------|-------------------------------|
| [`predict`](#cuml.dask.linear_model.ElasticNet.predict)(X[, delayed]) | Predicts the y for X.         |
<!-- !! processed by numpydoc !! -->

#### fit(X, y)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/linear_model/elastic_net.py#L81)

Fit the model with X and y.

* **Parameters:**
  **X**
  : Dense matrix (floats or doubles) of shape (n_samples, n_features).

  **y**
  : Dense vector (floats or doubles) of shape (n_samples,).

<!-- !! processed by numpydoc !! -->

#### get_combined_model()[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/common/base.py#L57)

Return single-GPU model for serialization

* **Returns:**
  **model**
  : yet been trained.

<!-- !! processed by numpydoc !! -->

#### predict(X, delayed=True)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/dask/linear_model/elastic_net.py#L97)

Predicts the y for X.

* **Parameters:**
  **X**
  : Dense matrix (floats or doubles) of shape (n_samples, n_features).

  **delayed**
  : Whether to do a lazy prediction (and return Delayed objects) or an
    eagerly executed one.
* **Returns:**
  **y**
  : Dense vector (floats or doubles) of shape (n_samples,).

<!-- !! processed by numpydoc !! -->
