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]#

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:
epsilonfloat, default=0.0

Epsilon parameter in the epsilon-insensitive loss function.

penalty{‘l1’, ‘l2’}, default = ‘l1’

The norm used in the penalization.

loss{‘epsilon_insensitive’, ‘squared_epsilon_insensitive’}, default=’epsilon_insensitive’

The loss function.

Cfloat, default=1.0

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

fit_interceptbool, default=True

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

penalized_interceptbool, default=False

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.

tolfloat, default=1e-4

Tolerance for the stopping criterion.

max_iterint, default=1000

Maximum number of iterations for the underlying solver.

linesearch_max_iterint, default=100

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

lbfgs_memoryint, default=5

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

verboseint or boolean, default=False

Sets logging level. It must be one of cuml.common.logger.level_*. See Verbosity Levels for more info.

output_type{‘input’, ‘array’, ‘dataframe’, ‘series’, ‘df_obj’, ‘numba’, ‘cupy’, ‘numpy’, ‘cudf’, ‘pandas’}, default=None

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 for more info.

Attributes:
coef_array, shape (1, n_features)

Weights assigned to the features (coefficients in the primal problem).

intercept_array or float, shape (1,)

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

n_iter_int

The number of iterations run during the fit.

Methods

fit(X, y[, sample_weight, convert_dtype])

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

Examples

>>> 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]
fit(X, y, sample_weight=None, *, convert_dtype=True) LinearSVR[source]#

Fit the model according to the given training data.

Parameters:
Xarray-like (device or host) shape = (n_samples, n_features)

Dense matrix. If datatype is other than floats or doubles, then the data will be converted to float which increases memory utilization. Set the parameter convert_dtype to False to avoid this, then the method will throw an error instead. Acceptable formats: CUDA array interface compliant objects like CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas DataFrame/Series.

yarray-like (device or host) shape = (n_samples, 1)

Dense matrix. If datatype is other than floats or doubles, then the data will be converted to float which increases memory utilization. Set the parameter convert_dtype to False to avoid this, then the method will throw an error instead. Acceptable formats: CUDA array interface compliant objects like CuPy, cuDF DataFrame/Series, NumPy ndarray and Pandas DataFrame/Series.

sample_weightarray-like (device or host) shape = (n_samples,), default=None

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

convert_dtypebool, optional (default = True)

When set to True, the train method will, when necessary, convert y to be the same data type as X if they differ. This will increase memory used for the method.