Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/source/api/cuml.linear_model.rst
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ cuml.linear_model
LinearRegression
LogisticRegression
Ridge
RidgeCV
Lasso
ElasticNet
MBSGDClassifier
Expand Down
3 changes: 3 additions & 0 deletions docs/source/api/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,9 @@ Regression and Classification
* - :obj:`~cuml.linear_model.Ridge`
- Ridge regression.
- :mod:`cuml.linear_model`
* - :obj:`~cuml.linear_model.RidgeCV`
- Ridge regression with built-in cross-validation.
- :mod:`cuml.linear_model`
* - :obj:`~cuml.solvers.SGD`
- Stochastic Gradient Descent solver.
- :mod:`cuml.solvers`
Expand Down
10 changes: 10 additions & 0 deletions docs/source/cuml-accel/compatibility.rst
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,16 @@ scores like ``sklearn.metrics.r2_score`` (for regression) or
- If ``positive=True`` or ``solver="lbfgs"``.


.. dropdown:: ``RidgeCV``
:name: ridgecv

``RidgeCV`` will fall back to CPU in the following cases:

- If ``cv`` is not ``None`` (only the default Leave-One-Out/GCV path is
accelerated on GPU).
- If a custom ``scoring`` is provided.


.. dropdown:: ``Lasso``
:name: lasso

Expand Down
2 changes: 2 additions & 0 deletions python/cuml/cuml/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
from cuml.linear_model.mbsgd_classifier import MBSGDClassifier
from cuml.linear_model.mbsgd_regressor import MBSGDRegressor
from cuml.linear_model.ridge import Ridge
from cuml.linear_model.ridge_cv import RidgeCV
from cuml.manifold.t_sne import TSNE
from cuml.manifold.umap import UMAP
from cuml.metrics import accuracy_score, adjusted_rand_score, r2_score
Expand Down Expand Up @@ -155,6 +156,7 @@ def __getattr__(name):
"RandomForestClassifier",
"RandomForestRegressor",
"Ridge",
"RidgeCV",
"SGD",
"SparseRandomProjection",
"SVC",
Expand Down
10 changes: 10 additions & 0 deletions python/cuml/cuml/accel/_overrides/sklearn/linear_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
"LogisticRegression",
"ElasticNet",
"Ridge",
"RidgeCV",
"Lasso",
)

Expand Down Expand Up @@ -63,6 +64,15 @@ def _gpu_fit(self, X, y, sample_weight=None):
return self


class RidgeCV(ProxyBase):
_gpu_class = cuml.linear_model.RidgeCV

def _gpu_fit(self, X, y, sample_weight=None, **params):
# `**params` is only used by sklearn for metadata routing, which we
# don't support; it's absorbed here to match sklearn's signature.
return self._gpu.fit(X, y, sample_weight=sample_weight)


class _ElasticNetMixin:
def _gpu_fit(self, X, y, sample_weight=None, check_input=True):
# check_input is ignored, only here to fix signature mismatch with sklearn
Expand Down
12 changes: 11 additions & 1 deletion python/cuml/cuml/benchmark/algorithms.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2019-2026, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
# SPDX-License-Identifier: Apache-2.0
#
import functools
Expand Down Expand Up @@ -389,6 +389,7 @@ def all_algorithms():
cuml_ElasticNet = cuml.linear_model.ElasticNet
cuml_Lasso = cuml.linear_model.Lasso
cuml_Ridge = cuml.linear_model.Ridge
cuml_RidgeCV = cuml.linear_model.RidgeCV
cuml_KernelRidge = cuml.kernel_ridge.KernelRidge
cuml_LogisticRegression = cuml.linear_model.LogisticRegression
cuml_RandomForestClassifier = cuml.ensemble.RandomForestClassifier
Expand Down Expand Up @@ -423,6 +424,7 @@ def all_algorithms():
cuml_LinearRegression = cuml_ElasticNet = cuml_Lasso = cuml_Ridge = (
None
)
cuml_RidgeCV = None
cuml_KernelRidge = None
cuml_LogisticRegression = None
cuml_RandomForestClassifier = cuml_RandomForestRegressor = None
Expand Down Expand Up @@ -575,6 +577,14 @@ def all_algorithms():
accepts_labels=True,
accuracy_function=metrics.r2_score,
),
AlgorithmPair(
sklearn.linear_model.RidgeCV,
cuml_RidgeCV,
shared_args={"alphas": np.logspace(-3, 3, 50)},
name="RidgeCV",
accepts_labels=True,
accuracy_function=metrics.r2_score,
),
AlgorithmPair(
sklearn.kernel_ridge.KernelRidge,
cuml_KernelRidge,
Expand Down
6 changes: 5 additions & 1 deletion python/cuml/cuml/benchmark/automated/bench_regression.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# SPDX-FileCopyrightText: Copyright (c) 2021-2025, NVIDIA CORPORATION.
# SPDX-FileCopyrightText: Copyright (c) 2021-2026, NVIDIA CORPORATION.
# SPDX-License-Identifier: Apache-2.0
#

Expand Down Expand Up @@ -64,6 +64,10 @@ def bench_ridge(gpubenchmark, bench_step, regression1): # noqa: F811
_benchmark_algo(gpubenchmark, "Ridge", bench_step, regression1)


def bench_ridge_cv(gpubenchmark, bench_step, regression1): # noqa: F811
_benchmark_algo(gpubenchmark, "RidgeCV", bench_step, regression1)


def bench_knnregressor(gpubenchmark, bench_step, regression1): # noqa: F811
_benchmark_algo(
gpubenchmark, "KNeighborsRegressor", bench_step, regression1
Expand Down
24 changes: 24 additions & 0 deletions python/cuml/cuml/benchmark/configs/single_gpu.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,30 @@ benchmarks:
default: {rows: [2600000]}
nightly: {rows: [10400000]}

- id: ridge_cv_fit
algorithm: RidgeCV
dataset: regression
operation: fit
tags: [linear, regression]
# RidgeCV runs a leave-one-out GCV over 50 alphas (O(n*p^2) per alpha), so
# it is much heavier than a single Ridge fit; row counts are scaled down.
variants:
narrow:
features: [16]
tiers:
default: {rows: [8000000]}
nightly: {rows: [16000000]}
medium:
features: [128]
tiers:
default: {rows: [1000000]}
nightly: {rows: [4000000]}
wide:
features: [512]
tiers:
default: {rows: [250000]}
nightly: {rows: [1000000]}

- id: elasticnet_fit
algorithm: ElasticNet
dataset: regression
Expand Down
1 change: 1 addition & 0 deletions python/cuml/cuml/linear_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
from cuml.linear_model.mbsgd_classifier import MBSGDClassifier
from cuml.linear_model.mbsgd_regressor import MBSGDRegressor
from cuml.linear_model.ridge import Ridge
from cuml.linear_model.ridge_cv import RidgeCV
Loading
Loading