scikit-learn-intelex 2024.2.0__py312-none-win_amd64.whl → 2024.4.0__py312-none-win_amd64.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.
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/__init__.py +9 -7
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/_device_offload.py +31 -4
- {scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex/spmd → scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex}/basic_statistics/__init__.py +2 -1
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/basic_statistics/incremental_basic_statistics.py +288 -0
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/basic_statistics/tests/test_incremental_basic_statistics.py +386 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/cluster/dbscan.py +3 -1
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/conftest.py +63 -0
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/decomposition/pca.py +335 -0
- scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/tests/test_preview_pca.py → scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/decomposition/tests/test_pca.py +22 -8
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/dispatcher.py +74 -43
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/ensemble/_forest.py +78 -89
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/ensemble/tests/test_forest.py +15 -19
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/linear_model/linear.py +316 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/linear_model/logistic_regression.py +63 -11
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/linear_model/tests/test_linear.py +40 -5
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/linear_model/tests/test_logreg.py +0 -2
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/neighbors/_lof.py +74 -20
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/neighbors/common.py +4 -1
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/neighbors/knn_classification.py +44 -131
- scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex/neighbors/knn_unsupervised.py → scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/neighbors/knn_regression.py +198 -221
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/neighbors/knn_unsupervised.py +146 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/neighbors/tests/test_neighbors.py +0 -5
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/preview/__init__.py +1 -1
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/k_means.py +5 -73
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/covariance.py +6 -5
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/tests/test_covariance.py +18 -5
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/ensemble/forest.py +4 -12
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/svm/_common.py +4 -7
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/svm/nusvc.py +70 -50
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/svm/nusvr.py +6 -52
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/svm/svc.py +70 -51
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/svm/svr.py +3 -49
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/tests/_utils.py +164 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/tests/test_memory_usage.py +8 -3
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/tests/test_monkeypatch.py +268 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/tests/test_n_jobs_support.py +8 -2
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/tests/test_parallel.py +6 -8
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/tests/test_patching.py +371 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/utils/__init__.py +2 -1
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/utils/_namespace.py +97 -0
- {scikit_learn_intelex-2024.2.0.dist-info → scikit_learn_intelex-2024.4.0.dist-info}/METADATA +2 -2
- scikit_learn_intelex-2024.4.0.dist-info/RECORD +101 -0
- scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex/decomposition/pca.py +0 -17
- scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex/decomposition/tests/test_pca.py +0 -27
- scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex/linear_model/linear.py +0 -381
- scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex/neighbors/knn_regression.py +0 -308
- scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/__init__.py +0 -19
- scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/pca.py +0 -374
- scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex/tests/_models_info.py +0 -170
- scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex/tests/test_monkeypatch.py +0 -240
- scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex/tests/test_patching.py +0 -136
- scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex/tests/utils/_launch_algorithms.py +0 -118
- scikit_learn_intelex-2024.2.0.dist-info/RECORD +0 -101
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/__main__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/_config.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/_utils.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/basic_statistics/basic_statistics.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/cluster/k_means.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/cluster/tests/test_dbscan.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/cluster/tests/test_kmeans.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/covariance/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/covariance/incremental_covariance.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/covariance/tests/test_incremental_covariance.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/decomposition/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/doc/third-party-programs.txt +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/ensemble/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/glob/__main__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/glob/dispatcher.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/linear_model/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/linear_model/coordinate_descent.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/linear_model/logistic_path.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/linear_model/ridge.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/manifold/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/manifold/t_sne.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/manifold/tests/test_tsne.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/metrics/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/metrics/pairwise.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/metrics/ranking.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/metrics/tests/test_metrics.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/model_selection/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/model_selection/split.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/model_selection/tests/test_model_selection.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/neighbors/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/_common.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data/data/Lib/site-packages/sklearnex → scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/spmd}/basic_statistics/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/basic_statistics/basic_statistics.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/dbscan.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/kmeans.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/covariance/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/covariance/covariance.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/decomposition/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/decomposition/pca.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/ensemble/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/linear_model.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/logistic_regression.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/neighbors/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/spmd/neighbors/neighbors.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/svm/__init__.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/svm/tests/test_svm.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/tests/test_config.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability_tests.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/utils/parallel.py +0 -0
- {scikit_learn_intelex-2024.2.0.data → scikit_learn_intelex-2024.4.0.data}/data/Lib/site-packages/sklearnex/utils/validation.py +0 -0
- {scikit_learn_intelex-2024.2.0.dist-info → scikit_learn_intelex-2024.4.0.dist-info}/LICENSE.txt +0 -0
- {scikit_learn_intelex-2024.2.0.dist-info → scikit_learn_intelex-2024.4.0.dist-info}/WHEEL +0 -0
- {scikit_learn_intelex-2024.2.0.dist-info → scikit_learn_intelex-2024.4.0.dist-info}/top_level.txt +0 -0
|
@@ -172,24 +172,6 @@ if daal_check_version((2023, "P", 200)):
|
|
|
172
172
|
return patching_status
|
|
173
173
|
|
|
174
174
|
def fit(self, X, y=None, sample_weight=None):
|
|
175
|
-
"""Compute k-means clustering.
|
|
176
|
-
|
|
177
|
-
Parameters
|
|
178
|
-
----------
|
|
179
|
-
X : array-like or sparse matrix, shape=(n_samples, n_features)
|
|
180
|
-
Training instances to cluster. It must be noted that the data
|
|
181
|
-
will be converted to C ordering, which will cause a memory
|
|
182
|
-
copy if the given data is not C-contiguous.
|
|
183
|
-
|
|
184
|
-
y : Ignored
|
|
185
|
-
not used, present here for API consistency by convention.
|
|
186
|
-
|
|
187
|
-
sample_weight : array-like, shape (n_samples,), optional
|
|
188
|
-
The weights for each observation in X. If None, all observations
|
|
189
|
-
are assigned equal weight (default: None)
|
|
190
|
-
|
|
191
|
-
"""
|
|
192
|
-
|
|
193
175
|
if sklearn_check_version("1.0"):
|
|
194
176
|
self._check_feature_names(X, reset=True)
|
|
195
177
|
if sklearn_check_version("1.2"):
|
|
@@ -257,24 +239,6 @@ if daal_check_version((2023, "P", 200)):
|
|
|
257
239
|
|
|
258
240
|
@wrap_output_data
|
|
259
241
|
def predict(self, X):
|
|
260
|
-
"""Compute k-means clustering.
|
|
261
|
-
|
|
262
|
-
Parameters
|
|
263
|
-
----------
|
|
264
|
-
X : array-like or sparse matrix, shape=(n_samples, n_features)
|
|
265
|
-
Training instances to cluster. It must be noted that the data
|
|
266
|
-
will be converted to C ordering, which will cause a memory
|
|
267
|
-
copy if the given data is not C-contiguous.
|
|
268
|
-
|
|
269
|
-
y : Ignored
|
|
270
|
-
not used, present here for API consistency by convention.
|
|
271
|
-
|
|
272
|
-
sample_weight : array-like, shape (n_samples,), optional
|
|
273
|
-
The weights for each observation in X. If None, all observations
|
|
274
|
-
are assigned equal weight (default: None)
|
|
275
|
-
|
|
276
|
-
"""
|
|
277
|
-
|
|
278
242
|
if sklearn_check_version("1.0"):
|
|
279
243
|
self._check_feature_names(X, reset=True)
|
|
280
244
|
if sklearn_check_version("1.2"):
|
|
@@ -317,52 +281,20 @@ if daal_check_version((2023, "P", 200)):
|
|
|
317
281
|
|
|
318
282
|
@wrap_output_data
|
|
319
283
|
def fit_transform(self, X, y=None, sample_weight=None):
|
|
320
|
-
"""Compute clustering and transform X to cluster-distance space.
|
|
321
|
-
|
|
322
|
-
Equivalent to fit(X).transform(X), but more efficiently implemented.
|
|
323
|
-
|
|
324
|
-
Parameters
|
|
325
|
-
----------
|
|
326
|
-
X : {array-like, sparse matrix} of shape (n_samples, n_features)
|
|
327
|
-
New data to transform.
|
|
328
|
-
|
|
329
|
-
y : Ignored
|
|
330
|
-
Not used, present here for API consistency by convention.
|
|
331
|
-
|
|
332
|
-
sample_weight : array-like of shape (n_samples,), default=None
|
|
333
|
-
The weights for each observation in X. If None, all observations
|
|
334
|
-
are assigned equal weight.
|
|
335
|
-
|
|
336
|
-
Returns
|
|
337
|
-
-------
|
|
338
|
-
X_new : ndarray of shape (n_samples, n_clusters)
|
|
339
|
-
X transformed in the new space.
|
|
340
|
-
"""
|
|
341
284
|
return self.fit(X, sample_weight=sample_weight)._transform(X)
|
|
342
285
|
|
|
343
286
|
@wrap_output_data
|
|
344
287
|
def transform(self, X):
|
|
345
|
-
"""Transform X to a cluster-distance space.
|
|
346
|
-
|
|
347
|
-
In the new space, each dimension is the distance to the cluster
|
|
348
|
-
centers. Note that even if X is sparse, the array returned by
|
|
349
|
-
`transform` will typically be dense.
|
|
350
|
-
|
|
351
|
-
Parameters
|
|
352
|
-
----------
|
|
353
|
-
X : {array-like, sparse matrix} of shape (n_samples, n_features)
|
|
354
|
-
New data to transform.
|
|
355
|
-
|
|
356
|
-
Returns
|
|
357
|
-
-------
|
|
358
|
-
X_new : ndarray of shape (n_samples, n_clusters)
|
|
359
|
-
X transformed in the new space.
|
|
360
|
-
"""
|
|
361
288
|
check_is_fitted(self)
|
|
362
289
|
|
|
363
290
|
X = self._check_test_data(X)
|
|
364
291
|
return self._transform(X)
|
|
365
292
|
|
|
293
|
+
fit.__doc__ = sklearn_KMeans.fit.__doc__
|
|
294
|
+
predict.__doc__ = sklearn_KMeans.predict.__doc__
|
|
295
|
+
transform.__doc__ = sklearn_KMeans.transform.__doc__
|
|
296
|
+
fit_transform.__doc__ = sklearn_KMeans.fit_transform.__doc__
|
|
297
|
+
|
|
366
298
|
else:
|
|
367
299
|
from daal4py.sklearn.cluster import KMeans
|
|
368
300
|
|
|
@@ -22,7 +22,7 @@ from sklearn.covariance import EmpiricalCovariance as sklearn_EmpiricalCovarianc
|
|
|
22
22
|
from sklearn.utils import check_array
|
|
23
23
|
|
|
24
24
|
from daal4py.sklearn._n_jobs_support import control_n_jobs
|
|
25
|
-
from daal4py.sklearn._utils import sklearn_check_version
|
|
25
|
+
from daal4py.sklearn._utils import daal_check_version, sklearn_check_version
|
|
26
26
|
from onedal.common.hyperparameters import get_hyperparameters
|
|
27
27
|
from onedal.covariance import EmpiricalCovariance as onedal_EmpiricalCovariance
|
|
28
28
|
from sklearnex import config_context
|
|
@@ -44,6 +44,10 @@ class EmpiricalCovariance(sklearn_EmpiricalCovariance):
|
|
|
44
44
|
|
|
45
45
|
def _save_attributes(self):
|
|
46
46
|
assert hasattr(self, "_onedal_estimator")
|
|
47
|
+
if not daal_check_version((2024, "P", 400)) and self.assume_centered:
|
|
48
|
+
location = self._onedal_estimator.location_[None, :]
|
|
49
|
+
self._onedal_estimator.covariance_ += np.dot(location.T, location)
|
|
50
|
+
self._onedal_estimator.location_ = np.zeros_like(np.squeeze(location))
|
|
47
51
|
self._set_covariance(self._onedal_estimator.covariance_)
|
|
48
52
|
self.location_ = self._onedal_estimator.location_
|
|
49
53
|
|
|
@@ -58,6 +62,7 @@ class EmpiricalCovariance(sklearn_EmpiricalCovariance):
|
|
|
58
62
|
onedal_params = {
|
|
59
63
|
"method": "dense",
|
|
60
64
|
"bias": True,
|
|
65
|
+
"assume_centered": self.assume_centered,
|
|
61
66
|
}
|
|
62
67
|
|
|
63
68
|
self._onedal_estimator = self._onedal_covariance(**onedal_params)
|
|
@@ -73,10 +78,6 @@ class EmpiricalCovariance(sklearn_EmpiricalCovariance):
|
|
|
73
78
|
(X,) = data
|
|
74
79
|
patching_status.and_conditions(
|
|
75
80
|
[
|
|
76
|
-
(
|
|
77
|
-
self.assume_centered == False,
|
|
78
|
-
"assume_centered parameter is not supported on oneDAL side",
|
|
79
|
-
),
|
|
80
81
|
(not sp.issparse(X), "X is sparse. Sparse input is not supported."),
|
|
81
82
|
]
|
|
82
83
|
)
|
|
@@ -27,27 +27,40 @@ from onedal.tests.utils._dataframes_support import (
|
|
|
27
27
|
|
|
28
28
|
@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
|
|
29
29
|
@pytest.mark.parametrize("macro_block", [None, 1024])
|
|
30
|
-
|
|
30
|
+
@pytest.mark.parametrize("assume_centered", [True, False])
|
|
31
|
+
def test_sklearnex_import_covariance(dataframe, queue, macro_block, assume_centered):
|
|
31
32
|
from sklearnex.preview.covariance import EmpiricalCovariance
|
|
32
33
|
|
|
33
34
|
X = np.array([[0, 1], [0, 1]])
|
|
35
|
+
|
|
34
36
|
X = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
|
|
35
|
-
empcov = EmpiricalCovariance()
|
|
37
|
+
empcov = EmpiricalCovariance(assume_centered=assume_centered)
|
|
36
38
|
if daal_check_version((2024, "P", 0)) and macro_block is not None:
|
|
37
39
|
hparams = empcov.get_hyperparameters("fit")
|
|
38
40
|
hparams.cpu_macro_block = macro_block
|
|
39
41
|
result = empcov.fit(X)
|
|
42
|
+
|
|
40
43
|
expected_covariance = np.array([[0, 0], [0, 0]])
|
|
41
|
-
expected_means = np.array([0,
|
|
44
|
+
expected_means = np.array([0, 0])
|
|
45
|
+
|
|
46
|
+
if assume_centered:
|
|
47
|
+
expected_covariance = np.array([[0, 0], [0, 1]])
|
|
48
|
+
else:
|
|
49
|
+
expected_means = np.array([0, 1])
|
|
42
50
|
|
|
43
51
|
assert_allclose(expected_covariance, result.covariance_)
|
|
44
52
|
assert_allclose(expected_means, result.location_)
|
|
45
53
|
|
|
46
54
|
X = np.array([[1, 2], [3, 6]])
|
|
55
|
+
|
|
47
56
|
X = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
|
|
48
57
|
result = empcov.fit(X)
|
|
49
|
-
|
|
50
|
-
|
|
58
|
+
|
|
59
|
+
if assume_centered:
|
|
60
|
+
expected_covariance = np.array([[5, 10], [10, 20]])
|
|
61
|
+
else:
|
|
62
|
+
expected_covariance = np.array([[1, 2], [2, 4]])
|
|
63
|
+
expected_means = np.array([2, 4])
|
|
51
64
|
|
|
52
65
|
assert_allclose(expected_covariance, result.covariance_)
|
|
53
66
|
assert_allclose(expected_means, result.location_)
|
|
@@ -14,8 +14,6 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
# ==============================================================================
|
|
16
16
|
|
|
17
|
-
from abc import ABC
|
|
18
|
-
|
|
19
17
|
from onedal.spmd.ensemble import RandomForestClassifier as onedal_RandomForestClassifier
|
|
20
18
|
from onedal.spmd.ensemble import RandomForestRegressor as onedal_RandomForestRegressor
|
|
21
19
|
|
|
@@ -23,16 +21,9 @@ from ...ensemble import RandomForestClassifier as RandomForestClassifier_Batch
|
|
|
23
21
|
from ...ensemble import RandomForestRegressor as RandomForestRegressor_Batch
|
|
24
22
|
|
|
25
23
|
|
|
26
|
-
class
|
|
27
|
-
def _onedal_classifier(self, **onedal_params):
|
|
28
|
-
return onedal_RandomForestClassifier(**onedal_params)
|
|
29
|
-
|
|
30
|
-
def _onedal_regressor(self, **onedal_params):
|
|
31
|
-
return onedal_RandomForestRegressor(**onedal_params)
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
class RandomForestClassifier(BaseForestSPMD, RandomForestClassifier_Batch):
|
|
24
|
+
class RandomForestClassifier(RandomForestClassifier_Batch):
|
|
35
25
|
__doc__ = RandomForestClassifier_Batch.__doc__
|
|
26
|
+
_onedal_factory = onedal_RandomForestClassifier
|
|
36
27
|
|
|
37
28
|
def _onedal_cpu_supported(self, method_name, *data):
|
|
38
29
|
# TODO:
|
|
@@ -55,8 +46,9 @@ class RandomForestClassifier(BaseForestSPMD, RandomForestClassifier_Batch):
|
|
|
55
46
|
return ready
|
|
56
47
|
|
|
57
48
|
|
|
58
|
-
class RandomForestRegressor(
|
|
49
|
+
class RandomForestRegressor(RandomForestRegressor_Batch):
|
|
59
50
|
__doc__ = RandomForestRegressor_Batch.__doc__
|
|
51
|
+
_onedal_factory = onedal_RandomForestRegressor
|
|
60
52
|
|
|
61
53
|
def _onedal_cpu_supported(self, method_name, *data):
|
|
62
54
|
# TODO:
|
|
@@ -76,7 +76,7 @@ class BaseSVM(ABC):
|
|
|
76
76
|
inference_methods = (
|
|
77
77
|
["predict"]
|
|
78
78
|
if class_name.endswith("R")
|
|
79
|
-
else ["predict", "predict_proba", "decision_function"]
|
|
79
|
+
else ["predict", "predict_proba", "decision_function", "score"]
|
|
80
80
|
)
|
|
81
81
|
if method_name in inference_methods:
|
|
82
82
|
patching_status.and_conditions(
|
|
@@ -111,12 +111,9 @@ class BaseSVC(BaseSVM):
|
|
|
111
111
|
cv = StratifiedKFold(
|
|
112
112
|
n_splits=n_splits, shuffle=True, random_state=self.random_state
|
|
113
113
|
)
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
)
|
|
118
|
-
else:
|
|
119
|
-
self.clf_prob = CalibratedClassifierCV(clf_base, cv=cv, method="sigmoid")
|
|
114
|
+
self.clf_prob = CalibratedClassifierCV(
|
|
115
|
+
clf_base, ensemble=False, cv=cv, method="sigmoid", n_jobs=n_jobs
|
|
116
|
+
)
|
|
120
117
|
self.clf_prob.fit(X, y, sample_weight)
|
|
121
118
|
except ValueError:
|
|
122
119
|
clf_base = clf_base.fit(X, y, sample_weight)
|
|
@@ -14,12 +14,15 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
# ==============================================================================
|
|
16
16
|
|
|
17
|
+
import numpy as np
|
|
17
18
|
from sklearn.exceptions import NotFittedError
|
|
19
|
+
from sklearn.metrics import accuracy_score
|
|
18
20
|
from sklearn.svm import NuSVC as sklearn_NuSVC
|
|
19
21
|
from sklearn.utils.validation import _deprecate_positional_args
|
|
20
22
|
|
|
21
23
|
from daal4py.sklearn._n_jobs_support import control_n_jobs
|
|
22
24
|
from daal4py.sklearn._utils import sklearn_check_version
|
|
25
|
+
from sklearnex.utils import get_namespace
|
|
23
26
|
|
|
24
27
|
from .._device_offload import dispatch, wrap_output_data
|
|
25
28
|
from ._common import BaseSVC
|
|
@@ -31,7 +34,7 @@ from onedal.svm import NuSVC as onedal_NuSVC
|
|
|
31
34
|
|
|
32
35
|
|
|
33
36
|
@control_n_jobs(
|
|
34
|
-
decorated_methods=["fit", "predict", "_predict_proba", "decision_function"]
|
|
37
|
+
decorated_methods=["fit", "predict", "_predict_proba", "decision_function", "score"]
|
|
35
38
|
)
|
|
36
39
|
class NuSVC(sklearn_NuSVC, BaseSVC):
|
|
37
40
|
__doc__ = sklearn_NuSVC.__doc__
|
|
@@ -78,39 +81,6 @@ class NuSVC(sklearn_NuSVC, BaseSVC):
|
|
|
78
81
|
)
|
|
79
82
|
|
|
80
83
|
def fit(self, X, y, sample_weight=None):
|
|
81
|
-
"""
|
|
82
|
-
Fit the SVM model according to the given training data.
|
|
83
|
-
|
|
84
|
-
Parameters
|
|
85
|
-
----------
|
|
86
|
-
X : {array-like, sparse matrix} of shape (n_samples, n_features) \
|
|
87
|
-
or (n_samples, n_samples)
|
|
88
|
-
Training vectors, where `n_samples` is the number of samples
|
|
89
|
-
and `n_features` is the number of features.
|
|
90
|
-
For kernel="precomputed", the expected shape of X is
|
|
91
|
-
(n_samples, n_samples).
|
|
92
|
-
|
|
93
|
-
y : array-like of shape (n_samples,)
|
|
94
|
-
Target values (class labels in classification, real numbers in
|
|
95
|
-
regression).
|
|
96
|
-
|
|
97
|
-
sample_weight : array-like of shape (n_samples,), default=None
|
|
98
|
-
Per-sample weights. Rescale C per sample. Higher weights
|
|
99
|
-
force the classifier to put more emphasis on these points.
|
|
100
|
-
|
|
101
|
-
Returns
|
|
102
|
-
-------
|
|
103
|
-
self : object
|
|
104
|
-
Fitted estimator.
|
|
105
|
-
|
|
106
|
-
Notes
|
|
107
|
-
-----
|
|
108
|
-
If X and y are not C-ordered and contiguous arrays of np.float64 and
|
|
109
|
-
X is not a scipy.sparse.csr_matrix, X and/or y may be copied.
|
|
110
|
-
|
|
111
|
-
If X is a dense array, then the other methods will not support sparse
|
|
112
|
-
matrices as input.
|
|
113
|
-
"""
|
|
114
84
|
if sklearn_check_version("1.2"):
|
|
115
85
|
self._validate_params()
|
|
116
86
|
if sklearn_check_version("1.0"):
|
|
@@ -131,22 +101,6 @@ class NuSVC(sklearn_NuSVC, BaseSVC):
|
|
|
131
101
|
|
|
132
102
|
@wrap_output_data
|
|
133
103
|
def predict(self, X):
|
|
134
|
-
"""
|
|
135
|
-
Perform regression on samples in X.
|
|
136
|
-
|
|
137
|
-
For an one-class model, +1 (inlier) or -1 (outlier) is returned.
|
|
138
|
-
|
|
139
|
-
Parameters
|
|
140
|
-
----------
|
|
141
|
-
X : {array-like, sparse matrix} of shape (n_samples, n_features)
|
|
142
|
-
For kernel="precomputed", the expected shape of X is
|
|
143
|
-
(n_samples_test, n_samples_train).
|
|
144
|
-
|
|
145
|
-
Returns
|
|
146
|
-
-------
|
|
147
|
-
y_pred : ndarray of shape (n_samples,)
|
|
148
|
-
The predicted values.
|
|
149
|
-
"""
|
|
150
104
|
if sklearn_check_version("1.0"):
|
|
151
105
|
self._check_feature_names(X, reset=False)
|
|
152
106
|
return dispatch(
|
|
@@ -159,6 +113,22 @@ class NuSVC(sklearn_NuSVC, BaseSVC):
|
|
|
159
113
|
X,
|
|
160
114
|
)
|
|
161
115
|
|
|
116
|
+
@wrap_output_data
|
|
117
|
+
def score(self, X, y, sample_weight=None):
|
|
118
|
+
if sklearn_check_version("1.0"):
|
|
119
|
+
self._check_feature_names(X, reset=False)
|
|
120
|
+
return dispatch(
|
|
121
|
+
self,
|
|
122
|
+
"score",
|
|
123
|
+
{
|
|
124
|
+
"onedal": self.__class__._onedal_score,
|
|
125
|
+
"sklearn": sklearn_NuSVC.score,
|
|
126
|
+
},
|
|
127
|
+
X,
|
|
128
|
+
y,
|
|
129
|
+
sample_weight=sample_weight,
|
|
130
|
+
)
|
|
131
|
+
|
|
162
132
|
if sklearn_check_version("1.0"):
|
|
163
133
|
|
|
164
134
|
@available_if(sklearn_NuSVC._check_proba)
|
|
@@ -191,6 +161,38 @@ class NuSVC(sklearn_NuSVC, BaseSVC):
|
|
|
191
161
|
"""
|
|
192
162
|
return self._predict_proba(X)
|
|
193
163
|
|
|
164
|
+
@available_if(sklearn_NuSVC._check_proba)
|
|
165
|
+
def predict_log_proba(self, X):
|
|
166
|
+
"""Compute log probabilities of possible outcomes for samples in X.
|
|
167
|
+
|
|
168
|
+
The model need to have probability information computed at training
|
|
169
|
+
time: fit with attribute `probability` set to True.
|
|
170
|
+
|
|
171
|
+
Parameters
|
|
172
|
+
----------
|
|
173
|
+
X : array-like of shape (n_samples, n_features) or \
|
|
174
|
+
(n_samples_test, n_samples_train)
|
|
175
|
+
For kernel="precomputed", the expected shape of X is
|
|
176
|
+
(n_samples_test, n_samples_train).
|
|
177
|
+
|
|
178
|
+
Returns
|
|
179
|
+
-------
|
|
180
|
+
T : ndarray of shape (n_samples, n_classes)
|
|
181
|
+
Returns the log-probabilities of the sample for each class in
|
|
182
|
+
the model. The columns correspond to the classes in sorted
|
|
183
|
+
order, as they appear in the attribute :term:`classes_`.
|
|
184
|
+
|
|
185
|
+
Notes
|
|
186
|
+
-----
|
|
187
|
+
The probability model is created using cross validation, so
|
|
188
|
+
the results can be slightly different than those obtained by
|
|
189
|
+
predict. Also, it will produce meaningless results on very small
|
|
190
|
+
datasets.
|
|
191
|
+
"""
|
|
192
|
+
xp, _ = get_namespace(X)
|
|
193
|
+
|
|
194
|
+
return xp.log(self.predict_proba(X))
|
|
195
|
+
|
|
194
196
|
else:
|
|
195
197
|
|
|
196
198
|
@property
|
|
@@ -198,6 +200,12 @@ class NuSVC(sklearn_NuSVC, BaseSVC):
|
|
|
198
200
|
self._check_proba()
|
|
199
201
|
return self._predict_proba
|
|
200
202
|
|
|
203
|
+
def _predict_log_proba(self, X):
|
|
204
|
+
xp, _ = get_namespace(X)
|
|
205
|
+
return xp.log(self.predict_proba(X))
|
|
206
|
+
|
|
207
|
+
predict_proba.__doc__ = sklearn_NuSVC.predict_proba.__doc__
|
|
208
|
+
|
|
201
209
|
@wrap_output_data
|
|
202
210
|
def _predict_proba(self, X):
|
|
203
211
|
if sklearn_check_version("1.0"):
|
|
@@ -232,6 +240,8 @@ class NuSVC(sklearn_NuSVC, BaseSVC):
|
|
|
232
240
|
X,
|
|
233
241
|
)
|
|
234
242
|
|
|
243
|
+
decision_function.__doc__ = sklearn_NuSVC.decision_function.__doc__
|
|
244
|
+
|
|
235
245
|
def _onedal_fit(self, X, y, sample_weight=None, queue=None):
|
|
236
246
|
onedal_params = {
|
|
237
247
|
"nu": self.nu,
|
|
@@ -274,3 +284,13 @@ class NuSVC(sklearn_NuSVC, BaseSVC):
|
|
|
274
284
|
|
|
275
285
|
def _onedal_decision_function(self, X, queue=None):
|
|
276
286
|
return self._onedal_estimator.decision_function(X, queue=queue)
|
|
287
|
+
|
|
288
|
+
def _onedal_score(self, X, y, sample_weight=None, queue=None):
|
|
289
|
+
return accuracy_score(
|
|
290
|
+
y, self._onedal_predict(X, queue=queue), sample_weight=sample_weight
|
|
291
|
+
)
|
|
292
|
+
|
|
293
|
+
fit.__doc__ = sklearn_NuSVC.fit.__doc__
|
|
294
|
+
predict.__doc__ = sklearn_NuSVC.predict.__doc__
|
|
295
|
+
decision_function.__doc__ = sklearn_NuSVC.decision_function.__doc__
|
|
296
|
+
score.__doc__ = sklearn_NuSVC.score.__doc__
|
|
@@ -36,14 +36,14 @@ class NuSVR(sklearn_NuSVR, BaseSVR):
|
|
|
36
36
|
def __init__(
|
|
37
37
|
self,
|
|
38
38
|
*,
|
|
39
|
+
nu=0.5,
|
|
40
|
+
C=1.0,
|
|
39
41
|
kernel="rbf",
|
|
40
42
|
degree=3,
|
|
41
43
|
gamma="scale",
|
|
42
44
|
coef0=0.0,
|
|
43
|
-
tol=1e-3,
|
|
44
|
-
C=1.0,
|
|
45
|
-
nu=0.5,
|
|
46
45
|
shrinking=True,
|
|
46
|
+
tol=1e-3,
|
|
47
47
|
cache_size=200,
|
|
48
48
|
verbose=False,
|
|
49
49
|
max_iter=-1,
|
|
@@ -63,39 +63,6 @@ class NuSVR(sklearn_NuSVR, BaseSVR):
|
|
|
63
63
|
)
|
|
64
64
|
|
|
65
65
|
def fit(self, X, y, sample_weight=None):
|
|
66
|
-
"""
|
|
67
|
-
Fit the SVM model according to the given training data.
|
|
68
|
-
|
|
69
|
-
Parameters
|
|
70
|
-
----------
|
|
71
|
-
X : {array-like, sparse matrix} of shape (n_samples, n_features) \
|
|
72
|
-
or (n_samples, n_samples)
|
|
73
|
-
Training vectors, where `n_samples` is the number of samples
|
|
74
|
-
and `n_features` is the number of features.
|
|
75
|
-
For kernel="precomputed", the expected shape of X is
|
|
76
|
-
(n_samples, n_samples).
|
|
77
|
-
|
|
78
|
-
y : array-like of shape (n_samples,)
|
|
79
|
-
Target values (class labels in classification, real numbers in
|
|
80
|
-
regression).
|
|
81
|
-
|
|
82
|
-
sample_weight : array-like of shape (n_samples,), default=None
|
|
83
|
-
Per-sample weights. Rescale C per sample. Higher weights
|
|
84
|
-
force the classifier to put more emphasis on these points.
|
|
85
|
-
|
|
86
|
-
Returns
|
|
87
|
-
-------
|
|
88
|
-
self : object
|
|
89
|
-
Fitted estimator.
|
|
90
|
-
|
|
91
|
-
Notes
|
|
92
|
-
-----
|
|
93
|
-
If X and y are not C-ordered and contiguous arrays of np.float64 and
|
|
94
|
-
X is not a scipy.sparse.csr_matrix, X and/or y may be copied.
|
|
95
|
-
|
|
96
|
-
If X is a dense array, then the other methods will not support sparse
|
|
97
|
-
matrices as input.
|
|
98
|
-
"""
|
|
99
66
|
if sklearn_check_version("1.2"):
|
|
100
67
|
self._validate_params()
|
|
101
68
|
if sklearn_check_version("1.0"):
|
|
@@ -115,22 +82,6 @@ class NuSVR(sklearn_NuSVR, BaseSVR):
|
|
|
115
82
|
|
|
116
83
|
@wrap_output_data
|
|
117
84
|
def predict(self, X):
|
|
118
|
-
"""
|
|
119
|
-
Perform regression on samples in X.
|
|
120
|
-
|
|
121
|
-
For an one-class model, +1 (inlier) or -1 (outlier) is returned.
|
|
122
|
-
|
|
123
|
-
Parameters
|
|
124
|
-
----------
|
|
125
|
-
X : {array-like, sparse matrix} of shape (n_samples, n_features)
|
|
126
|
-
For kernel="precomputed", the expected shape of X is
|
|
127
|
-
(n_samples_test, n_samples_train).
|
|
128
|
-
|
|
129
|
-
Returns
|
|
130
|
-
-------
|
|
131
|
-
y_pred : ndarray of shape (n_samples,)
|
|
132
|
-
The predicted values.
|
|
133
|
-
"""
|
|
134
85
|
if sklearn_check_version("1.0"):
|
|
135
86
|
self._check_feature_names(X, reset=False)
|
|
136
87
|
return dispatch(
|
|
@@ -163,3 +114,6 @@ class NuSVR(sklearn_NuSVR, BaseSVR):
|
|
|
163
114
|
|
|
164
115
|
def _onedal_predict(self, X, queue=None):
|
|
165
116
|
return self._onedal_estimator.predict(X, queue=queue)
|
|
117
|
+
|
|
118
|
+
fit.__doc__ = sklearn_NuSVR.fit.__doc__
|
|
119
|
+
predict.__doc__ = sklearn_NuSVR.predict.__doc__
|