# SVR

### *class* cuml.svm.SVR(Epsilon Support Vector Regression)[[source]](https://github.com/NVIDIA/cuml/blob/93418baf5/python/cuml/cuml/svm/svr.py#L12)

* **Parameters:**
  **C**
  : Penalty parameter C

  **kernel**
  : Specifies the kernel function. Possible options: ‘linear’, ‘poly’,
    ‘rbf’, ‘sigmoid’, ‘precomputed’. When using ‘precomputed’, X is
    expected to be a precomputed kernel matrix of shape
    (n_samples, n_samples) at fit time, and (n_samples_test,
    n_samples_train) at predict time. A valid kernel matrix should be
    symmetric and positive semi-definite; cuML does not validate these
    properties.

  **degree**
  : Degree of polynomial kernel function.

  **gamma**
  : Coefficient for rbf, poly, and sigmoid kernels. You can specify the
    numeric value, or use one of the following options:
    - ‘auto’: gamma will be set to `1 / n_features`
    - ‘scale’: gamma will be se to `1 / (n_features * X.var())`

  **coef0**
  : Independent term in kernel function, only significant for poly and
    sigmoid

  **tol**
  : Tolerance for stopping criterion.

  **epsilon: float (default = 0.1)**
  : epsilon parameter of the epsilon-SVR model. There is no penalty
    associated to points that are predicted within the epsilon-tube
    around the target values.

  **cache_size**
  : Size of the kernel cache during training in MiB. Increase it to improve
    the training time, at the cost of higher memory footprint. After
    training the kernel cache is deallocated.
    During prediction, we also need a temporary space to store kernel
    matrix elements (this can be significant if n_support is large).
    The cache_size variable sets an upper limit to the prediction
    buffer as well.

  **max_iter**
  : Limit the number of total iterations in the solver. Default of -1 for
    “no limit”.

  **nochange_steps**
  : We monitor how much our stopping criteria changes during outer
    iterations. If it does not change (changes less then 1e-3\*tol)
    for nochange_steps consecutive steps, then we stop training.

  **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:**
  **n_support_**
  : The total number of support vectors. Note: this will change in the
    future to represent number support vectors for each class (like
    in Sklearn, see Issue #956)

  **support_**
  : Device array of support vector indices

  **support_vectors_**
  : Device array of support vectors. For kernel=’precomputed’, this
    attribute is empty (shape [0, 0]) since the original feature vectors
    are not available.

  **dual_coef_**
  : Device array of coefficients for support vectors

  **intercept_**
  : The constant in the decision function

  **fit_status_**
  : 0 if SVM is correctly fitted

  **n_iter_**
  : Number of outer iterations run by the solver.

  [`coef_`](#cuml.svm.SVR.coef_)
  : SVMBase.coef_(self)

### Methods

| [`fit`](#cuml.svm.SVR.fit)(X, y[, sample_weight])   | Fit the model with X and y.   |
|-------------------------------------------------------------------------------|-------------------------------|
| [`predict`](#cuml.svm.SVR.predict)(X)                   | Predicts the values for X.    |

### Notes

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

The solver uses the SMO method to fit the regressor. We use the Optimized
Hierarchical Decomposition [[1]](#rb8bccbcfd254-1) variant of the SMO algorithm, similar to
[[2]](#rb8bccbcfd254-2)

### References

### Examples

```python
>>> import cupy as cp
>>> from cuml.svm import SVR
>>> X = cp.array([[1], [2], [3], [4], [5]], dtype=cp.float32)
>>> y = cp.array([1.1, 4, 5, 3.9, 1.], dtype = cp.float32)
>>> reg = SVR(kernel='rbf', gamma='scale', C=10, epsilon=0.1)
>>> reg.fit(X, y)
SVR(C=10)
>>> print("Predicted values:", reg.predict(X))
Predicted values: [1.200474 3.8999617 5.100488 3.7995374 1.0995375]
```

<!-- !! 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 !! -->

#### *property* coef_

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

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

Fit the model with X and y.

* **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/svm/svr.py#L162)

Predicts the values for X.

For precomputed kernels, X should be a kernel matrix of shape
(n_samples_test, n_samples_train) where n_samples_train is the
number of samples used during fit.

* **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 !! -->
