scikit-learn-intelex 2024.4.0__py310-none-manylinux1_x86_64.whl → 2024.6.0__py310-none-manylinux1_x86_64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of scikit-learn-intelex might be problematic. Click here for more details.
- {scikit_learn_intelex-2024.4.0.dist-info → scikit_learn_intelex-2024.6.0.dist-info}/METADATA +2 -2
- {scikit_learn_intelex-2024.4.0.dist-info → scikit_learn_intelex-2024.6.0.dist-info}/RECORD +43 -36
- sklearnex/_device_offload.py +8 -1
- sklearnex/basic_statistics/tests/test_incremental_basic_statistics.py +2 -4
- sklearnex/cluster/dbscan.py +3 -0
- sklearnex/cluster/tests/test_dbscan.py +8 -6
- sklearnex/conftest.py +11 -1
- sklearnex/covariance/incremental_covariance.py +217 -30
- sklearnex/covariance/tests/test_incremental_covariance.py +54 -17
- sklearnex/decomposition/pca.py +68 -13
- sklearnex/decomposition/tests/test_pca.py +6 -4
- sklearnex/dispatcher.py +46 -1
- sklearnex/ensemble/_forest.py +114 -22
- sklearnex/ensemble/tests/test_forest.py +13 -3
- sklearnex/glob/dispatcher.py +16 -2
- sklearnex/linear_model/__init__.py +5 -3
- sklearnex/linear_model/incremental_linear.py +464 -0
- sklearnex/linear_model/linear.py +27 -9
- sklearnex/linear_model/logistic_regression.py +13 -15
- sklearnex/linear_model/tests/test_incremental_linear.py +200 -0
- sklearnex/linear_model/tests/test_linear.py +2 -2
- sklearnex/neighbors/knn_regression.py +24 -0
- sklearnex/neighbors/tests/test_neighbors.py +2 -2
- sklearnex/preview/__init__.py +1 -1
- sklearnex/preview/decomposition/__init__.py +19 -0
- sklearnex/preview/decomposition/incremental_pca.py +228 -0
- sklearnex/preview/decomposition/tests/test_incremental_pca.py +266 -0
- sklearnex/svm/_common.py +165 -20
- sklearnex/svm/nusvc.py +40 -4
- sklearnex/svm/nusvr.py +31 -2
- sklearnex/svm/svc.py +40 -4
- sklearnex/svm/svr.py +31 -2
- sklearnex/tests/_utils.py +70 -29
- sklearnex/tests/test_common.py +54 -0
- sklearnex/tests/test_memory_usage.py +195 -132
- sklearnex/tests/test_n_jobs_support.py +4 -0
- sklearnex/tests/test_patching.py +22 -10
- sklearnex/tests/test_run_to_run_stability.py +283 -0
- sklearnex/utils/_namespace.py +1 -1
- sklearnex/utils/tests/test_finite.py +89 -0
- sklearnex/tests/test_run_to_run_stability_tests.py +0 -428
- {scikit_learn_intelex-2024.4.0.dist-info → scikit_learn_intelex-2024.6.0.dist-info}/LICENSE.txt +0 -0
- {scikit_learn_intelex-2024.4.0.dist-info → scikit_learn_intelex-2024.6.0.dist-info}/WHEEL +0 -0
- {scikit_learn_intelex-2024.4.0.dist-info → scikit_learn_intelex-2024.6.0.dist-info}/top_level.txt +0 -0
|
@@ -17,6 +17,10 @@
|
|
|
17
17
|
import numpy as np
|
|
18
18
|
import pytest
|
|
19
19
|
from numpy.testing import assert_allclose
|
|
20
|
+
from sklearn.covariance.tests.test_covariance import (
|
|
21
|
+
test_covariance,
|
|
22
|
+
test_EmpiricalCovariance_validates_mahalanobis,
|
|
23
|
+
)
|
|
20
24
|
|
|
21
25
|
from onedal.tests.utils._dataframes_support import (
|
|
22
26
|
_convert_to_dataframe,
|
|
@@ -26,13 +30,14 @@ from onedal.tests.utils._dataframes_support import (
|
|
|
26
30
|
|
|
27
31
|
@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
|
|
28
32
|
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
|
|
29
|
-
|
|
33
|
+
@pytest.mark.parametrize("assume_centered", [True, False])
|
|
34
|
+
def test_sklearnex_partial_fit_on_gold_data(dataframe, queue, dtype, assume_centered):
|
|
30
35
|
from sklearnex.covariance import IncrementalEmpiricalCovariance
|
|
31
36
|
|
|
32
37
|
X = np.array([[0, 1], [0, 1]])
|
|
33
38
|
X = X.astype(dtype)
|
|
34
39
|
X_split = np.array_split(X, 2)
|
|
35
|
-
inccov = IncrementalEmpiricalCovariance()
|
|
40
|
+
inccov = IncrementalEmpiricalCovariance(assume_centered=assume_centered)
|
|
36
41
|
|
|
37
42
|
for i in range(2):
|
|
38
43
|
X_split_df = _convert_to_dataframe(
|
|
@@ -40,8 +45,12 @@ def test_sklearnex_partial_fit_on_gold_data(dataframe, queue, dtype):
|
|
|
40
45
|
)
|
|
41
46
|
result = inccov.partial_fit(X_split_df)
|
|
42
47
|
|
|
43
|
-
|
|
44
|
-
|
|
48
|
+
if assume_centered:
|
|
49
|
+
expected_covariance = np.array([[0, 0], [0, 1]])
|
|
50
|
+
expected_means = np.array([0, 0])
|
|
51
|
+
else:
|
|
52
|
+
expected_covariance = np.array([[0, 0], [0, 0]])
|
|
53
|
+
expected_means = np.array([0, 1])
|
|
45
54
|
|
|
46
55
|
assert_allclose(expected_covariance, result.covariance_)
|
|
47
56
|
assert_allclose(expected_means, result.location_)
|
|
@@ -49,7 +58,7 @@ def test_sklearnex_partial_fit_on_gold_data(dataframe, queue, dtype):
|
|
|
49
58
|
X = np.array([[1, 2], [3, 6]])
|
|
50
59
|
X = X.astype(dtype)
|
|
51
60
|
X_split = np.array_split(X, 2)
|
|
52
|
-
inccov = IncrementalEmpiricalCovariance()
|
|
61
|
+
inccov = IncrementalEmpiricalCovariance(assume_centered=assume_centered)
|
|
53
62
|
|
|
54
63
|
for i in range(2):
|
|
55
64
|
X_split_df = _convert_to_dataframe(
|
|
@@ -57,8 +66,12 @@ def test_sklearnex_partial_fit_on_gold_data(dataframe, queue, dtype):
|
|
|
57
66
|
)
|
|
58
67
|
result = inccov.partial_fit(X_split_df)
|
|
59
68
|
|
|
60
|
-
|
|
61
|
-
|
|
69
|
+
if assume_centered:
|
|
70
|
+
expected_covariance = np.array([[5, 10], [10, 20]])
|
|
71
|
+
expected_means = np.array([0, 0])
|
|
72
|
+
else:
|
|
73
|
+
expected_covariance = np.array([[1, 2], [2, 4]])
|
|
74
|
+
expected_means = np.array([2, 4])
|
|
62
75
|
|
|
63
76
|
assert_allclose(expected_covariance, result.covariance_)
|
|
64
77
|
assert_allclose(expected_means, result.location_)
|
|
@@ -87,9 +100,9 @@ def test_sklearnex_fit_on_gold_data(dataframe, queue, batch_size, dtype):
|
|
|
87
100
|
|
|
88
101
|
|
|
89
102
|
@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
|
|
90
|
-
@pytest.mark.parametrize("num_batches", [2,
|
|
91
|
-
@pytest.mark.parametrize("row_count", [100, 1000
|
|
92
|
-
@pytest.mark.parametrize("column_count", [10, 100
|
|
103
|
+
@pytest.mark.parametrize("num_batches", [2, 10])
|
|
104
|
+
@pytest.mark.parametrize("row_count", [100, 1000])
|
|
105
|
+
@pytest.mark.parametrize("column_count", [10, 100])
|
|
93
106
|
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
|
|
94
107
|
def test_sklearnex_partial_fit_on_random_data(
|
|
95
108
|
dataframe, queue, num_batches, row_count, column_count, dtype
|
|
@@ -117,12 +130,13 @@ def test_sklearnex_partial_fit_on_random_data(
|
|
|
117
130
|
|
|
118
131
|
|
|
119
132
|
@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
|
|
120
|
-
@pytest.mark.parametrize("num_batches", [2,
|
|
121
|
-
@pytest.mark.parametrize("row_count", [100, 1000
|
|
122
|
-
@pytest.mark.parametrize("column_count", [10, 100
|
|
133
|
+
@pytest.mark.parametrize("num_batches", [2, 10])
|
|
134
|
+
@pytest.mark.parametrize("row_count", [100, 1000])
|
|
135
|
+
@pytest.mark.parametrize("column_count", [10, 100])
|
|
123
136
|
@pytest.mark.parametrize("dtype", [np.float32, np.float64])
|
|
137
|
+
@pytest.mark.parametrize("assume_centered", [True, False])
|
|
124
138
|
def test_sklearnex_fit_on_random_data(
|
|
125
|
-
dataframe, queue, num_batches, row_count, column_count, dtype
|
|
139
|
+
dataframe, queue, num_batches, row_count, column_count, dtype, assume_centered
|
|
126
140
|
):
|
|
127
141
|
from sklearnex.covariance import IncrementalEmpiricalCovariance
|
|
128
142
|
|
|
@@ -132,12 +146,35 @@ def test_sklearnex_fit_on_random_data(
|
|
|
132
146
|
X = X.astype(dtype)
|
|
133
147
|
X_df = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
|
|
134
148
|
batch_size = row_count // num_batches
|
|
135
|
-
inccov = IncrementalEmpiricalCovariance(
|
|
149
|
+
inccov = IncrementalEmpiricalCovariance(
|
|
150
|
+
batch_size=batch_size, assume_centered=assume_centered
|
|
151
|
+
)
|
|
136
152
|
|
|
137
153
|
result = inccov.fit(X_df)
|
|
138
154
|
|
|
139
|
-
|
|
140
|
-
|
|
155
|
+
if assume_centered:
|
|
156
|
+
expected_covariance = np.dot(X.T, X) / X.shape[0]
|
|
157
|
+
expected_means = np.zeros_like(X[0])
|
|
158
|
+
else:
|
|
159
|
+
expected_covariance = np.cov(X.T, bias=1)
|
|
160
|
+
expected_means = np.mean(X, axis=0)
|
|
141
161
|
|
|
142
162
|
assert_allclose(expected_covariance, result.covariance_, atol=1e-6)
|
|
143
163
|
assert_allclose(expected_means, result.location_, atol=1e-6)
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
# Monkeypatch IncrementalEmpiricalCovariance into relevant sklearn.covariance tests
|
|
167
|
+
@pytest.mark.allow_sklearn_fallback
|
|
168
|
+
@pytest.mark.parametrize(
|
|
169
|
+
"sklearn_test",
|
|
170
|
+
[
|
|
171
|
+
test_covariance,
|
|
172
|
+
test_EmpiricalCovariance_validates_mahalanobis,
|
|
173
|
+
],
|
|
174
|
+
)
|
|
175
|
+
def test_IncrementalEmpiricalCovariance_against_sklearn(monkeypatch, sklearn_test):
|
|
176
|
+
from sklearnex.covariance import IncrementalEmpiricalCovariance
|
|
177
|
+
|
|
178
|
+
class_name = ".".join([sklearn_test.__module__, "EmpiricalCovariance"])
|
|
179
|
+
monkeypatch.setattr(class_name, IncrementalEmpiricalCovariance)
|
|
180
|
+
sklearn_test()
|
sklearnex/decomposition/pca.py
CHANGED
|
@@ -21,6 +21,7 @@ from daal4py.sklearn._utils import daal_check_version
|
|
|
21
21
|
if daal_check_version((2024, "P", 100)):
|
|
22
22
|
import numbers
|
|
23
23
|
from math import sqrt
|
|
24
|
+
from warnings import warn
|
|
24
25
|
|
|
25
26
|
import numpy as np
|
|
26
27
|
from scipy.sparse import issparse
|
|
@@ -35,9 +36,13 @@ if daal_check_version((2024, "P", 100)):
|
|
|
35
36
|
if sklearn_check_version("1.1") and not sklearn_check_version("1.2"):
|
|
36
37
|
from sklearn.utils import check_scalar
|
|
37
38
|
|
|
39
|
+
if sklearn_check_version("1.2"):
|
|
40
|
+
from sklearn.utils._param_validation import StrOptions
|
|
41
|
+
|
|
38
42
|
from sklearn.decomposition import PCA as sklearn_PCA
|
|
39
43
|
|
|
40
44
|
from onedal.decomposition import PCA as onedal_PCA
|
|
45
|
+
from sklearnex.utils import get_namespace
|
|
41
46
|
|
|
42
47
|
@control_n_jobs(decorated_methods=["fit", "transform", "fit_transform"])
|
|
43
48
|
class PCA(sklearn_PCA):
|
|
@@ -45,6 +50,16 @@ if daal_check_version((2024, "P", 100)):
|
|
|
45
50
|
|
|
46
51
|
if sklearn_check_version("1.2"):
|
|
47
52
|
_parameter_constraints: dict = {**sklearn_PCA._parameter_constraints}
|
|
53
|
+
# "onedal_svd" solver uses oneDAL's PCA-SVD algorithm
|
|
54
|
+
# and required for testing purposes to fully enable it in future.
|
|
55
|
+
# "covariance_eigh" solver is added for ability to explicitly request
|
|
56
|
+
# oneDAL's PCA-Covariance algorithm using any sklearn version < 1.5.
|
|
57
|
+
_parameter_constraints["svd_solver"] = [
|
|
58
|
+
StrOptions(
|
|
59
|
+
_parameter_constraints["svd_solver"][0].options
|
|
60
|
+
| {"onedal_svd", "covariance_eigh"}
|
|
61
|
+
)
|
|
62
|
+
]
|
|
48
63
|
|
|
49
64
|
if sklearn_check_version("1.1"):
|
|
50
65
|
|
|
@@ -107,7 +122,7 @@ if daal_check_version((2024, "P", 100)):
|
|
|
107
122
|
target_type=numbers.Integral,
|
|
108
123
|
)
|
|
109
124
|
|
|
110
|
-
|
|
125
|
+
return dispatch(
|
|
111
126
|
self,
|
|
112
127
|
"fit",
|
|
113
128
|
{
|
|
@@ -116,7 +131,6 @@ if daal_check_version((2024, "P", 100)):
|
|
|
116
131
|
},
|
|
117
132
|
X,
|
|
118
133
|
)
|
|
119
|
-
return U, S, Vt
|
|
120
134
|
|
|
121
135
|
def _onedal_fit(self, X, queue=None):
|
|
122
136
|
X = self._validate_data(
|
|
@@ -129,7 +143,7 @@ if daal_check_version((2024, "P", 100)):
|
|
|
129
143
|
onedal_params = {
|
|
130
144
|
"n_components": self.n_components,
|
|
131
145
|
"is_deterministic": True,
|
|
132
|
-
"method": "cov",
|
|
146
|
+
"method": "svd" if self._fit_svd_solver == "onedal_svd" else "cov",
|
|
133
147
|
"whiten": self.whiten,
|
|
134
148
|
}
|
|
135
149
|
self._onedal_estimator = onedal_PCA(**onedal_params)
|
|
@@ -140,7 +154,13 @@ if daal_check_version((2024, "P", 100)):
|
|
|
140
154
|
S = self.singular_values_
|
|
141
155
|
Vt = self.components_
|
|
142
156
|
|
|
143
|
-
|
|
157
|
+
if sklearn_check_version("1.5"):
|
|
158
|
+
xp, _ = get_namespace(X)
|
|
159
|
+
x_is_centered = not self.copy
|
|
160
|
+
|
|
161
|
+
return U, S, Vt, X, x_is_centered, xp
|
|
162
|
+
else:
|
|
163
|
+
return U, S, Vt
|
|
144
164
|
|
|
145
165
|
@wrap_output_data
|
|
146
166
|
def transform(self, X):
|
|
@@ -156,32 +176,39 @@ if daal_check_version((2024, "P", 100)):
|
|
|
156
176
|
|
|
157
177
|
def _onedal_transform(self, X, queue=None):
|
|
158
178
|
check_is_fitted(self)
|
|
179
|
+
if sklearn_check_version("1.0"):
|
|
180
|
+
self._check_feature_names(X, reset=False)
|
|
159
181
|
X = self._validate_data(
|
|
160
182
|
X,
|
|
161
183
|
dtype=[np.float64, np.float32],
|
|
162
184
|
reset=False,
|
|
163
185
|
)
|
|
164
186
|
self._validate_n_features_in_after_fitting(X)
|
|
165
|
-
if sklearn_check_version("1.0"):
|
|
166
|
-
self._check_feature_names(X, reset=False)
|
|
167
187
|
|
|
168
188
|
return self._onedal_estimator.predict(X, queue=queue)
|
|
169
189
|
|
|
170
190
|
def fit_transform(self, X, y=None):
|
|
171
|
-
|
|
172
|
-
|
|
191
|
+
if sklearn_check_version("1.5"):
|
|
192
|
+
U, S, Vt, X_fit, x_is_centered, xp = self._fit(X)
|
|
193
|
+
else:
|
|
194
|
+
U, S, Vt = self._fit(X)
|
|
195
|
+
X_fit = X
|
|
196
|
+
if hasattr(self, "_onedal_estimator"):
|
|
173
197
|
# oneDAL PCA was fit
|
|
174
198
|
return self.transform(X)
|
|
175
|
-
|
|
199
|
+
elif U is not None:
|
|
176
200
|
# Scikit-learn PCA was fit
|
|
177
201
|
U = U[:, : self.n_components_]
|
|
178
202
|
|
|
179
203
|
if self.whiten:
|
|
180
|
-
U *= sqrt(
|
|
204
|
+
U *= sqrt(X_fit.shape[0] - 1)
|
|
181
205
|
else:
|
|
182
206
|
U *= S[: self.n_components_]
|
|
183
207
|
|
|
184
208
|
return U
|
|
209
|
+
else:
|
|
210
|
+
# Scikit-learn PCA["covariance_eigh"] was fit
|
|
211
|
+
return self._transform(X_fit, xp, x_is_centered=x_is_centered)
|
|
185
212
|
|
|
186
213
|
def _onedal_supported(self, method_name, X):
|
|
187
214
|
class_name = self.__class__.__name__
|
|
@@ -199,7 +226,13 @@ if daal_check_version((2024, "P", 100)):
|
|
|
199
226
|
),
|
|
200
227
|
(
|
|
201
228
|
self._is_solver_compatible_with_onedal(shape_tuple),
|
|
202
|
-
|
|
229
|
+
(
|
|
230
|
+
"Only 'covariance_eigh' and 'onedal_svd' "
|
|
231
|
+
"solvers are supported."
|
|
232
|
+
if sklearn_check_version("1.5")
|
|
233
|
+
else "Only 'full', 'covariance_eigh' and 'onedal_svd' "
|
|
234
|
+
"solvers are supported."
|
|
235
|
+
),
|
|
203
236
|
),
|
|
204
237
|
(not issparse(X), "oneDAL PCA does not support sparse data"),
|
|
205
238
|
]
|
|
@@ -254,7 +287,13 @@ if daal_check_version((2024, "P", 100)):
|
|
|
254
287
|
|
|
255
288
|
if self._fit_svd_solver == "auto":
|
|
256
289
|
if sklearn_check_version("1.1"):
|
|
257
|
-
if
|
|
290
|
+
if (
|
|
291
|
+
sklearn_check_version("1.5")
|
|
292
|
+
and shape_tuple[1] <= 1_000
|
|
293
|
+
and shape_tuple[0] >= 10 * shape_tuple[1]
|
|
294
|
+
):
|
|
295
|
+
self._fit_svd_solver = "covariance_eigh"
|
|
296
|
+
elif max(shape_tuple) <= 500 or n_components == "mle":
|
|
258
297
|
self._fit_svd_solver = "full"
|
|
259
298
|
elif 1 <= n_components < 0.8 * n_sf_min:
|
|
260
299
|
self._fit_svd_solver = "randomized"
|
|
@@ -288,7 +327,23 @@ if daal_check_version((2024, "P", 100)):
|
|
|
288
327
|
else:
|
|
289
328
|
self._fit_svd_solver = "full"
|
|
290
329
|
|
|
291
|
-
|
|
330
|
+
# Use oneDAL in next cases:
|
|
331
|
+
# 1. oneDAL SVD solver is explicitly set
|
|
332
|
+
# 2. solver is set or dispatched to "covariance_eigh"
|
|
333
|
+
# 3. solver is set or dispatched to "full" and sklearn version < 1.5
|
|
334
|
+
# 4. solver is set to "auto" and dispatched to "full"
|
|
335
|
+
if self._fit_svd_solver in ["onedal_svd", "covariance_eigh"]:
|
|
336
|
+
return True
|
|
337
|
+
elif not sklearn_check_version("1.5") and self._fit_svd_solver == "full":
|
|
338
|
+
self._fit_svd_solver = "covariance_eigh"
|
|
339
|
+
return True
|
|
340
|
+
elif self.svd_solver == "auto" and self._fit_svd_solver == "full":
|
|
341
|
+
warn(
|
|
342
|
+
"Sklearnex always uses `covariance_eigh` solver instead of `full` "
|
|
343
|
+
"when `svd_solver` parameter is set to `auto` "
|
|
344
|
+
"for performance purposes."
|
|
345
|
+
)
|
|
346
|
+
self._fit_svd_solver = "covariance_eigh"
|
|
292
347
|
return True
|
|
293
348
|
else:
|
|
294
349
|
return False
|
|
@@ -41,16 +41,18 @@ def test_sklearnex_import(dataframe, queue):
|
|
|
41
41
|
[3.6053038, 0.04224385],
|
|
42
42
|
]
|
|
43
43
|
|
|
44
|
-
pca = PCA(n_components=2, svd_solver="
|
|
44
|
+
pca = PCA(n_components=2, svd_solver="covariance_eigh")
|
|
45
45
|
pca.fit(X)
|
|
46
46
|
X_transformed = pca.transform(X)
|
|
47
|
-
X_fit_transformed = PCA(n_components=2, svd_solver="
|
|
47
|
+
X_fit_transformed = PCA(n_components=2, svd_solver="covariance_eigh").fit_transform(X)
|
|
48
48
|
|
|
49
49
|
if daal_check_version((2024, "P", 100)):
|
|
50
50
|
assert "sklearnex" in pca.__module__
|
|
51
51
|
assert hasattr(pca, "_onedal_estimator")
|
|
52
52
|
else:
|
|
53
53
|
assert "daal4py" in pca.__module__
|
|
54
|
+
|
|
55
|
+
tol = 1e-5 if _as_numpy(X_transformed).dtype == np.float32 else 1e-7
|
|
54
56
|
assert_allclose([6.30061232, 0.54980396], _as_numpy(pca.singular_values_))
|
|
55
|
-
assert_allclose(X_transformed_expected, _as_numpy(X_transformed))
|
|
56
|
-
assert_allclose(X_transformed_expected, _as_numpy(X_fit_transformed))
|
|
57
|
+
assert_allclose(X_transformed_expected, _as_numpy(X_transformed), rtol=tol)
|
|
58
|
+
assert_allclose(X_transformed_expected, _as_numpy(X_fit_transformed), rtol=tol)
|
sklearnex/dispatcher.py
CHANGED
|
@@ -45,12 +45,14 @@ def get_patch_map_core(preview=False):
|
|
|
45
45
|
|
|
46
46
|
if _is_new_patching_available():
|
|
47
47
|
import sklearn.covariance as covariance_module
|
|
48
|
+
import sklearn.decomposition as decomposition_module
|
|
48
49
|
|
|
49
50
|
# Preview classes for patching
|
|
50
51
|
from .preview.cluster import KMeans as KMeans_sklearnex
|
|
51
52
|
from .preview.covariance import (
|
|
52
53
|
EmpiricalCovariance as EmpiricalCovariance_sklearnex,
|
|
53
54
|
)
|
|
55
|
+
from .preview.decomposition import IncrementalPCA as IncrementalPCA_sklearnex
|
|
54
56
|
|
|
55
57
|
# Since the state of the lru_cache without preview cannot be
|
|
56
58
|
# guaranteed to not have already enabled sklearnex algorithms
|
|
@@ -62,7 +64,7 @@ def get_patch_map_core(preview=False):
|
|
|
62
64
|
sklearn_obj = mapping["kmeans"][0][1]
|
|
63
65
|
mapping.pop("kmeans")
|
|
64
66
|
mapping["kmeans"] = [
|
|
65
|
-
[(cluster_module, "
|
|
67
|
+
[(cluster_module, "KMeans", KMeans_sklearnex), sklearn_obj]
|
|
66
68
|
]
|
|
67
69
|
|
|
68
70
|
# Covariance
|
|
@@ -76,6 +78,18 @@ def get_patch_map_core(preview=False):
|
|
|
76
78
|
None,
|
|
77
79
|
]
|
|
78
80
|
]
|
|
81
|
+
|
|
82
|
+
# IncrementalPCA
|
|
83
|
+
mapping["incrementalpca"] = [
|
|
84
|
+
[
|
|
85
|
+
(
|
|
86
|
+
decomposition_module,
|
|
87
|
+
"IncrementalPCA",
|
|
88
|
+
IncrementalPCA_sklearnex,
|
|
89
|
+
),
|
|
90
|
+
None,
|
|
91
|
+
]
|
|
92
|
+
]
|
|
79
93
|
return mapping
|
|
80
94
|
|
|
81
95
|
from daal4py.sklearn.monkeypatch.dispatcher import _get_map_of_algorithms
|
|
@@ -93,6 +107,7 @@ def get_patch_map_core(preview=False):
|
|
|
93
107
|
# Scikit-learn* modules
|
|
94
108
|
import sklearn as base_module
|
|
95
109
|
import sklearn.cluster as cluster_module
|
|
110
|
+
import sklearn.covariance as covariance_module
|
|
96
111
|
import sklearn.decomposition as decomposition_module
|
|
97
112
|
import sklearn.ensemble as ensemble_module
|
|
98
113
|
import sklearn.linear_model as linear_model_module
|
|
@@ -115,11 +130,17 @@ def get_patch_map_core(preview=False):
|
|
|
115
130
|
from .utils.parallel import _FuncWrapperOld as _FuncWrapper_sklearnex
|
|
116
131
|
|
|
117
132
|
from .cluster import DBSCAN as DBSCAN_sklearnex
|
|
133
|
+
from .covariance import (
|
|
134
|
+
IncrementalEmpiricalCovariance as IncrementalEmpiricalCovariance_sklearnex,
|
|
135
|
+
)
|
|
118
136
|
from .decomposition import PCA as PCA_sklearnex
|
|
119
137
|
from .ensemble import ExtraTreesClassifier as ExtraTreesClassifier_sklearnex
|
|
120
138
|
from .ensemble import ExtraTreesRegressor as ExtraTreesRegressor_sklearnex
|
|
121
139
|
from .ensemble import RandomForestClassifier as RandomForestClassifier_sklearnex
|
|
122
140
|
from .ensemble import RandomForestRegressor as RandomForestRegressor_sklearnex
|
|
141
|
+
from .linear_model import (
|
|
142
|
+
IncrementalLinearRegression as IncrementalLinearRegression_sklearnex,
|
|
143
|
+
)
|
|
123
144
|
from .linear_model import LinearRegression as LinearRegression_sklearnex
|
|
124
145
|
from .linear_model import LogisticRegression as LogisticRegression_sklearnex
|
|
125
146
|
from .neighbors import KNeighborsClassifier as KNeighborsClassifier_sklearnex
|
|
@@ -273,6 +294,30 @@ def get_patch_map_core(preview=False):
|
|
|
273
294
|
]
|
|
274
295
|
mapping["localoutlierfactor"] = mapping["lof"]
|
|
275
296
|
|
|
297
|
+
# IncrementalEmpiricalCovariance
|
|
298
|
+
mapping["incrementalempiricalcovariance"] = [
|
|
299
|
+
[
|
|
300
|
+
(
|
|
301
|
+
covariance_module,
|
|
302
|
+
"IncrementalEmpiricalCovariance",
|
|
303
|
+
IncrementalEmpiricalCovariance_sklearnex,
|
|
304
|
+
),
|
|
305
|
+
None,
|
|
306
|
+
]
|
|
307
|
+
]
|
|
308
|
+
|
|
309
|
+
# IncrementalLinearRegression
|
|
310
|
+
mapping["incrementallinearregression"] = [
|
|
311
|
+
[
|
|
312
|
+
(
|
|
313
|
+
linear_model_module,
|
|
314
|
+
"IncrementalLinearRegression",
|
|
315
|
+
IncrementalLinearRegression_sklearnex,
|
|
316
|
+
),
|
|
317
|
+
None,
|
|
318
|
+
]
|
|
319
|
+
]
|
|
320
|
+
|
|
276
321
|
# Configs
|
|
277
322
|
mapping["set_config"] = [
|
|
278
323
|
[(base_module, "set_config", set_config_sklearnex), None]
|