# LinearSVR

### *class* cuml.svm.LinearSVR(, epsilon=0.0, penalty='l1', loss='epsilon_insensitive', C=1.0, fit_intercept=True, penalized_intercept=False, tol=0.0001, max_iter=1000, linesearch_max_iter=100, lbfgs_memory=5, verbose=False, output_type=None)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/svm/linear_svr.py#L17)

Linear Support Vector Regression.

Similar to SVR with parameter kernel=’linear’, but implemented using a
linear solver. This enables flexibility in penalties and loss functions,
and can scale better for larger problems.

* **Parameters:**
  **epsilon**
  : Epsilon parameter in the epsilon-insensitive loss function.

  **penalty**
  : The norm used in the penalization.

  **loss**
  : The loss function.

  **C**
  : Regularization parameter. The strength of the regularization is
    inversely proportional to C. Must be strictly positive.

  **fit_intercept**
  : Whether to fit the bias term. Set to False if you expect that the
    data is already centered.

  **penalized_intercept**
  : When true, the bias term is treated the same way as other features;
    i.e. it’s penalized by the regularization term of the target function.
    Enabling this feature forces an extra copying the input data X.

  **tol**
  : Tolerance for the stopping criterion.

  **max_iter**
  : Maximum number of iterations for the underlying solver.

  **linesearch_max_iter**
  : Maximum number of linesearch (inner loop) iterations for
    the underlying (QN) solver.

  **lbfgs_memory**
  : Number of vectors approximating the hessian for the underlying QN
    solver (l-bfgs).

  **verbose**
  : Sets logging level. It must be one of `cuml.common.logger.level_*`.
    See [Verbosity Levels](../../cuml/index.html.md#verbosity-levels) for more info.

  **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_**
  : Weights assigned to the features (coefficients in the primal problem).

  **intercept_**
  : The constant factor in the decision function. If
    `fit_intercept=False` this is instead a float with value 0.0.

  **n_iter_**
  : The number of iterations run during the fit.

### Methods

| [`fit`](#cuml.svm.LinearSVR.fit)(X, y[, sample_weight])   | Fit the model according to the given training data.   |
|-------------------------------------------------------------------------------|-------------------------------------------------------|

### Notes

The model uses the quasi-newton (QN) solver to find the solution in the
primal space. Thus, in contrast to generic [`SVC`](../cuml.svm.SVR/index.html.md#cuml.svm.SVR)
model, it does not compute the support coefficients/vectors.

Check the solver’s documentation for more details
`Quasi-Newton (L-BFGS/OWL-QN)`.

For additional docs, see [scikitlearn’s LinearSVR](https://scikit-learn.org/stable/modules/generated/sklearn.svm.LinearSVR.html).

### Examples

```pycon
>>> import cupy as cp
>>> from cuml.svm import LinearSVR
>>> X = cp.array([[1], [2], [3], [4], [5]], dtype=cp.float32)
>>> y = cp.array([1.1, 4, 5, 3.9, 8.], dtype=cp.float32)
>>> reg = LinearSVR(epsilon=0.1, C=10).fit(X, y)
>>> print("Predicted values:", reg.predict(X))
Predicted values: [1.8993504 3.3995128 4.899675  6.399837  7.899999]
```

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

#### as_sklearn()[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/internals/interop.py#L206)

Convert this estimator into an equivalent scikit-learn (or scikit-learn
extension) estimator.

* **Returns:**
  sklearn.base.BaseEstimator
  : A scikit-learn compatible estimator instance that mirrors the trained
    state of the current estimator.

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

#### fit(X, y, sample_weight=None) → [LinearSVR](#cuml.svm.LinearSVR)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/svm/linear_svr.py#L200)

Fit the model according to the given training data.

* **Parameters:**
  **X**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

  **y**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

  **sample_weight**
  : The weights for each observation in X. If None, all observations
    are assigned equal weight.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

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

#### *classmethod* from_sklearn(model)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/internals/interop.py#L222)

Create a cuml estimator from a scikit-learn estimator.

* **Parameters:**
  **model**
  : A compatible scikit-learn (or scikit-learn extension) estimator.
* **Returns:**
  cls
  : A new instance of this cuml estimator class that mirrors the
    state of the input estimator.

### Notes

`output_type` of the estimator is set to “numpy” by default, as these
cannot be inferred from training arguments. If something different is
required, then please use cuml’s output_type configuration utilities.

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

#### get_params(deep=True)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/internals/base.py#L191)

Returns a dict of all params owned by this class. If the child class
has appropriately overridden the `_get_param_names` method and does not
need anything other than what is there in this method, then it doesn’t
have to override this method

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

#### predict(X)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/linear_model/base.py#L14)

Predicts `y` values for `X`.

* **Parameters:**
  **X**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.
* **Returns:**
  **preds**
  : Predicted values
    <br/>
    For more information on how to configure cuML’s output type,
    refer to: [Output Data Type Configuration](../../cuml/index.html.md#output-data-type-configuration).

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

#### score(X, y, sample_weight=None, \*\*kwargs)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/internals/mixins.py#L66)

Scoring function for regression estimators

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

* **Parameters:**
  **X**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

  **y**
  : Dense matrix with dtype float32 or float64.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.

  **sample_weight**
  : The weights for each observation in X. If None, all observations
    are assigned equal weight.
    Acceptable formats: CUDA array interface compliant objects like
    CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas
    DataFrame/Series.
* **Returns:**
  **score**
  : R^2 of self.predict(X) wrt. y.

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

#### set_params(\*\*params)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/internals/base.py#L200)

Accepts a dict of params and updates the corresponding ones owned by
this class. If the child class has appropriately overridden the
`_get_param_names` method and does not need anything other than what is,
there in this method, then it doesn’t have to override this method

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