Skip to content

Commit

Permalink
ENH: Moving Ridge out of preview (#2154)
Browse files Browse the repository at this point in the history
  • Loading branch information
DDJHB authored Dec 2, 2024
1 parent 8a09904 commit 6c7c6a5
Show file tree
Hide file tree
Showing 14 changed files with 647 additions and 629 deletions.
9 changes: 3 additions & 6 deletions doc/sources/preview.rst
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ Then, you can import Scikit-learn estimator patched with a preview one from `skl

from sklearnex import patch_sklearn
patch_sklearn()
from sklearn.linear_model import Ridge
print(Ridge.__module__)
from sklearn.decomposition import IncrementalPCA
print(IncrementalPCA.__module__)
# output:
# sklearnex.preview.linear_model.ridge
# sklearnex.preview.decomposition.incremental_pca

Current list of preview estimators:

Expand All @@ -71,6 +71,3 @@ Current list of preview estimators:
* - IncrementalPCA
- sklearnex.preview.decomposition
- Yes
* - Ridge
- sklearnex.preview.linear_model
- Yes
16 changes: 8 additions & 8 deletions onedal/linear_model/linear_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -293,15 +293,15 @@ def fit(self, X, y, queue=None):
"""
module = self._get_backend("linear_model", "regression")

X = _check_array(
X,
dtype=[np.float64, np.float32],
force_all_finite=False,
ensure_2d=False,
copy=self.copy_X,
)
if not isinstance(X, np.ndarray):
X = np.asarray(X)

dtype = get_dtype(X)
if dtype not in [np.float32, np.float64]:
dtype = np.float64
X = X.astype(dtype, copy=self.copy_X)

y = np.asarray(y).astype(dtype=get_dtype(X))
y = np.asarray(y).astype(dtype=dtype)

X, y = _check_X_y(X, y, force_all_finite=False, accept_2d_y=True)

Expand Down
1 change: 0 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,6 @@ def run(self):
"sklearnex.preview",
"sklearnex.preview.covariance",
"sklearnex.preview.decomposition",
"sklearnex.preview.linear_model",
"sklearnex.svm",
"sklearnex.utils",
]
Expand Down
9 changes: 0 additions & 9 deletions sklearnex/dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ def get_patch_map_core(preview=False):
EmpiricalCovariance as EmpiricalCovariance_sklearnex,
)
from .preview.decomposition import IncrementalPCA as IncrementalPCA_sklearnex
from .preview.linear_model import Ridge as Ridge_sklearnex

# Since the state of the lru_cache without preview cannot be
# guaranteed to not have already enabled sklearnex algorithms
Expand Down Expand Up @@ -83,14 +82,6 @@ def get_patch_map_core(preview=False):
]
]

# Ridge
linear_model_module, _, _ = mapping["ridge"][0][0]
sklearn_obj = mapping["ridge"][0][1]
mapping.pop("ridge")
mapping["ridge"] = [
[(linear_model_module, "Ridge", Ridge_sklearnex), sklearn_obj]
]

return mapping

from daal4py.sklearn.monkeypatch.dispatcher import _get_map_of_algorithms
Expand Down
Loading

0 comments on commit 6c7c6a5

Please sign in to comment.