scikit-learn-intelex 2024.1.0__py39-none-win_amd64.whl → 2024.3.0__py39-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.
Potentially problematic release.
This version of scikit-learn-intelex might be problematic. Click here for more details.
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/__init__.py +9 -7
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/cluster/dbscan.py +6 -4
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/conftest.py +63 -0
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/covariance/__init__.py +19 -0
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/covariance/incremental_covariance.py +130 -0
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/covariance/tests/test_incremental_covariance.py +143 -0
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/decomposition/pca.py +338 -0
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/tests/test_preview_pca.py → scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/decomposition/tests/test_pca.py +22 -8
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/dispatcher.py +91 -59
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/ensemble/_forest.py +15 -24
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/ensemble/tests/test_forest.py +15 -19
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/linear_model/__init__.py +1 -2
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/linear_model/linear.py +3 -10
- {scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/preview → scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex}/linear_model/logistic_regression.py +32 -40
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_logreg.py +91 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/neighbors/__init__.py +1 -1
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/neighbors/_lof.py +204 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/neighbors/knn_classification.py +13 -18
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/neighbors/knn_regression.py +12 -17
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/neighbors/knn_unsupervised.py +10 -15
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/neighbors/tests/test_neighbors.py +12 -16
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/preview/__init__.py +1 -1
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/k_means.py +3 -8
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/covariance.py +46 -12
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/__init__.py +1 -0
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/__init__.py +19 -0
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/covariance.py +21 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/ensemble/forest.py +4 -12
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/__init__.py +2 -1
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/logistic_regression.py +21 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/svm/nusvc.py +9 -6
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/svm/nusvr.py +6 -7
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/svm/svc.py +9 -6
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/svm/svr.py +3 -4
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/tests/_utils.py +155 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/tests/test_memory_usage.py +9 -7
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/tests/test_monkeypatch.py +268 -0
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/tests/test_n_jobs_support.py +93 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/tests/test_parallel.py +6 -8
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/tests/test_patching.py +361 -0
- {scikit_learn_intelex-2024.1.0.dist-info → scikit_learn_intelex-2024.3.0.dist-info}/METADATA +2 -2
- scikit_learn_intelex-2024.3.0.dist-info/RECORD +98 -0
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/decomposition/pca.py +0 -17
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/decomposition/tests/test_pca.py +0 -27
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_logreg.py +0 -28
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/neighbors/lof.py +0 -436
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/__init__.py +0 -19
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/pca.py +0 -376
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/preview/linear_model/__init__.py +0 -19
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/preview/linear_model/tests/test_preview_logistic_regression.py +0 -59
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/tests/_models_info.py +0 -170
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/tests/test_monkeypatch.py +0 -227
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/tests/test_n_jobs_support.py +0 -31
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/tests/test_patching.py +0 -122
- scikit_learn_intelex-2024.1.0.data/data/Lib/site-packages/sklearnex/tests/utils/_launch_algorithms.py +0 -118
- scikit_learn_intelex-2024.1.0.dist-info/RECORD +0 -97
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/__main__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/_config.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/_device_offload.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/_utils.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/basic_statistics/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/basic_statistics/basic_statistics.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/cluster/k_means.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/cluster/tests/test_dbscan.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/cluster/tests/test_kmeans.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/decomposition/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/doc/third-party-programs.txt +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/ensemble/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/glob/__main__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/glob/dispatcher.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/linear_model/coordinate_descent.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/linear_model/logistic_path.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/linear_model/ridge.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/linear_model/tests/test_linear.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/manifold/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/manifold/t_sne.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/manifold/tests/test_tsne.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/metrics/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/metrics/pairwise.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/metrics/ranking.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/metrics/tests/test_metrics.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/model_selection/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/model_selection/split.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/model_selection/tests/test_model_selection.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/neighbors/common.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/_common.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/tests/test_covariance.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/basic_statistics/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/basic_statistics/basic_statistics.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/dbscan.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/kmeans.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/decomposition/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/decomposition/pca.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/ensemble/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/linear_model.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/neighbors/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/spmd/neighbors/neighbors.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/svm/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/svm/_common.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/svm/tests/test_svm.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/tests/test_config.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability_tests.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/utils/__init__.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/utils/parallel.py +0 -0
- {scikit_learn_intelex-2024.1.0.data → scikit_learn_intelex-2024.3.0.data}/data/Lib/site-packages/sklearnex/utils/validation.py +0 -0
- {scikit_learn_intelex-2024.1.0.dist-info → scikit_learn_intelex-2024.3.0.dist-info}/LICENSE.txt +0 -0
- {scikit_learn_intelex-2024.1.0.dist-info → scikit_learn_intelex-2024.3.0.dist-info}/WHEEL +0 -0
- {scikit_learn_intelex-2024.1.0.dist-info → scikit_learn_intelex-2024.3.0.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,268 @@
|
|
|
1
|
+
# ===============================================================================
|
|
2
|
+
# Copyright 2021 Intel Corporation
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
# ===============================================================================
|
|
16
|
+
|
|
17
|
+
import sklearnex
|
|
18
|
+
from daal4py.sklearn._utils import daal_check_version
|
|
19
|
+
|
|
20
|
+
# General use of patch_sklearn and unpatch_sklearn in pytest is not recommended.
|
|
21
|
+
# It changes global state and can impact the operation of other tests. This file
|
|
22
|
+
# specifically tests patch_sklearn and unpatch_sklearn and is exempt from this.
|
|
23
|
+
# If sklearnex patching is necessary in testing, use the 'with_sklearnex' pytest
|
|
24
|
+
# fixture.
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def test_monkey_patching():
|
|
28
|
+
_tokens = sklearnex.get_patch_names()
|
|
29
|
+
_values = sklearnex.get_patch_map().values()
|
|
30
|
+
_classes = list()
|
|
31
|
+
|
|
32
|
+
for v in _values:
|
|
33
|
+
for c in v:
|
|
34
|
+
_classes.append(c[0])
|
|
35
|
+
|
|
36
|
+
try:
|
|
37
|
+
sklearnex.patch_sklearn()
|
|
38
|
+
|
|
39
|
+
for i, _ in enumerate(_tokens):
|
|
40
|
+
t = _tokens[i]
|
|
41
|
+
p = _classes[i][0]
|
|
42
|
+
n = _classes[i][1]
|
|
43
|
+
|
|
44
|
+
class_module = getattr(p, n).__module__
|
|
45
|
+
assert class_module.startswith("daal4py") or class_module.startswith(
|
|
46
|
+
"sklearnex"
|
|
47
|
+
), "Patching has completed with error."
|
|
48
|
+
|
|
49
|
+
for i, _ in enumerate(_tokens):
|
|
50
|
+
t = _tokens[i]
|
|
51
|
+
p = _classes[i][0]
|
|
52
|
+
n = _classes[i][1]
|
|
53
|
+
|
|
54
|
+
sklearnex.unpatch_sklearn(t)
|
|
55
|
+
sklearn_class = getattr(p, n, None)
|
|
56
|
+
if sklearn_class is not None:
|
|
57
|
+
sklearn_class = sklearn_class.__module__
|
|
58
|
+
assert sklearn_class is None or sklearn_class.startswith(
|
|
59
|
+
"sklearn"
|
|
60
|
+
), "Unpatching has completed with error."
|
|
61
|
+
|
|
62
|
+
finally:
|
|
63
|
+
sklearnex.unpatch_sklearn()
|
|
64
|
+
|
|
65
|
+
try:
|
|
66
|
+
for i, _ in enumerate(_tokens):
|
|
67
|
+
t = _tokens[i]
|
|
68
|
+
p = _classes[i][0]
|
|
69
|
+
n = _classes[i][1]
|
|
70
|
+
|
|
71
|
+
sklearn_class = getattr(p, n, None)
|
|
72
|
+
if sklearn_class is not None:
|
|
73
|
+
sklearn_class = sklearn_class.__module__
|
|
74
|
+
assert sklearn_class is None or sklearn_class.startswith(
|
|
75
|
+
"sklearn"
|
|
76
|
+
), "Unpatching has completed with error."
|
|
77
|
+
|
|
78
|
+
finally:
|
|
79
|
+
sklearnex.unpatch_sklearn()
|
|
80
|
+
|
|
81
|
+
try:
|
|
82
|
+
for i, _ in enumerate(_tokens):
|
|
83
|
+
t = _tokens[i]
|
|
84
|
+
p = _classes[i][0]
|
|
85
|
+
n = _classes[i][1]
|
|
86
|
+
|
|
87
|
+
sklearnex.patch_sklearn(t)
|
|
88
|
+
|
|
89
|
+
class_module = getattr(p, n).__module__
|
|
90
|
+
assert class_module.startswith("daal4py") or class_module.startswith(
|
|
91
|
+
"sklearnex"
|
|
92
|
+
), "Patching has completed with error."
|
|
93
|
+
finally:
|
|
94
|
+
sklearnex.unpatch_sklearn()
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
def test_patch_by_list_simple():
|
|
98
|
+
try:
|
|
99
|
+
sklearnex.patch_sklearn(["LogisticRegression"])
|
|
100
|
+
|
|
101
|
+
from sklearn.ensemble import RandomForestRegressor
|
|
102
|
+
from sklearn.linear_model import LogisticRegression
|
|
103
|
+
from sklearn.neighbors import KNeighborsRegressor
|
|
104
|
+
from sklearn.svm import SVC
|
|
105
|
+
|
|
106
|
+
assert RandomForestRegressor.__module__.startswith("sklearn")
|
|
107
|
+
assert KNeighborsRegressor.__module__.startswith("sklearn")
|
|
108
|
+
if daal_check_version((2024, "P", 1)):
|
|
109
|
+
assert LogisticRegression.__module__.startswith("sklearnex")
|
|
110
|
+
else:
|
|
111
|
+
assert LogisticRegression.__module__.startswith("daal4py")
|
|
112
|
+
assert SVC.__module__.startswith("sklearn")
|
|
113
|
+
finally:
|
|
114
|
+
sklearnex.unpatch_sklearn()
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def test_patch_by_list_many_estimators():
|
|
118
|
+
try:
|
|
119
|
+
sklearnex.patch_sklearn(["LogisticRegression", "SVC"])
|
|
120
|
+
|
|
121
|
+
from sklearn.ensemble import RandomForestRegressor
|
|
122
|
+
from sklearn.linear_model import LogisticRegression
|
|
123
|
+
from sklearn.neighbors import KNeighborsRegressor
|
|
124
|
+
from sklearn.svm import SVC
|
|
125
|
+
|
|
126
|
+
assert RandomForestRegressor.__module__.startswith("sklearn")
|
|
127
|
+
assert KNeighborsRegressor.__module__.startswith("sklearn")
|
|
128
|
+
if daal_check_version((2024, "P", 1)):
|
|
129
|
+
assert LogisticRegression.__module__.startswith("sklearnex")
|
|
130
|
+
else:
|
|
131
|
+
assert LogisticRegression.__module__.startswith("daal4py")
|
|
132
|
+
assert SVC.__module__.startswith("daal4py") or SVC.__module__.startswith(
|
|
133
|
+
"sklearnex"
|
|
134
|
+
)
|
|
135
|
+
|
|
136
|
+
finally:
|
|
137
|
+
sklearnex.unpatch_sklearn()
|
|
138
|
+
|
|
139
|
+
|
|
140
|
+
def test_unpatch_by_list_many_estimators():
|
|
141
|
+
try:
|
|
142
|
+
sklearnex.patch_sklearn()
|
|
143
|
+
|
|
144
|
+
from sklearn.ensemble import RandomForestRegressor
|
|
145
|
+
from sklearn.linear_model import LogisticRegression
|
|
146
|
+
from sklearn.neighbors import KNeighborsRegressor
|
|
147
|
+
from sklearn.svm import SVC
|
|
148
|
+
|
|
149
|
+
assert RandomForestRegressor.__module__.startswith("sklearnex")
|
|
150
|
+
assert KNeighborsRegressor.__module__.startswith(
|
|
151
|
+
"daal4py"
|
|
152
|
+
) or KNeighborsRegressor.__module__.startswith("sklearnex")
|
|
153
|
+
if daal_check_version((2024, "P", 1)):
|
|
154
|
+
assert LogisticRegression.__module__.startswith("sklearnex")
|
|
155
|
+
else:
|
|
156
|
+
assert LogisticRegression.__module__.startswith("daal4py")
|
|
157
|
+
assert SVC.__module__.startswith("daal4py") or SVC.__module__.startswith(
|
|
158
|
+
"sklearnex"
|
|
159
|
+
)
|
|
160
|
+
|
|
161
|
+
sklearnex.unpatch_sklearn(["KNeighborsRegressor", "RandomForestRegressor"])
|
|
162
|
+
|
|
163
|
+
from sklearn.ensemble import RandomForestRegressor
|
|
164
|
+
from sklearn.linear_model import LogisticRegression
|
|
165
|
+
from sklearn.neighbors import KNeighborsRegressor
|
|
166
|
+
from sklearn.svm import SVC
|
|
167
|
+
|
|
168
|
+
assert RandomForestRegressor.__module__.startswith("sklearn")
|
|
169
|
+
assert KNeighborsRegressor.__module__.startswith("sklearn")
|
|
170
|
+
if daal_check_version((2024, "P", 1)):
|
|
171
|
+
assert LogisticRegression.__module__.startswith("sklearnex")
|
|
172
|
+
else:
|
|
173
|
+
assert LogisticRegression.__module__.startswith("daal4py")
|
|
174
|
+
|
|
175
|
+
assert SVC.__module__.startswith("daal4py") or SVC.__module__.startswith(
|
|
176
|
+
"sklearnex"
|
|
177
|
+
)
|
|
178
|
+
finally:
|
|
179
|
+
sklearnex.unpatch_sklearn()
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
def test_patching_checker():
|
|
183
|
+
for name in [None, "SVC", "PCA"]:
|
|
184
|
+
try:
|
|
185
|
+
sklearnex.patch_sklearn(name=name)
|
|
186
|
+
assert sklearnex.sklearn_is_patched(name=name)
|
|
187
|
+
|
|
188
|
+
finally:
|
|
189
|
+
sklearnex.unpatch_sklearn(name=name)
|
|
190
|
+
assert not sklearnex.sklearn_is_patched(name=name)
|
|
191
|
+
try:
|
|
192
|
+
sklearnex.patch_sklearn()
|
|
193
|
+
patching_status_map = sklearnex.sklearn_is_patched(return_map=True)
|
|
194
|
+
assert len(patching_status_map) == len(sklearnex.get_patch_names())
|
|
195
|
+
for status in patching_status_map.values():
|
|
196
|
+
assert status
|
|
197
|
+
finally:
|
|
198
|
+
sklearnex.unpatch_sklearn()
|
|
199
|
+
|
|
200
|
+
patching_status_map = sklearnex.sklearn_is_patched(return_map=True)
|
|
201
|
+
assert len(patching_status_map) == len(sklearnex.get_patch_names())
|
|
202
|
+
for status in patching_status_map.values():
|
|
203
|
+
assert not status
|
|
204
|
+
|
|
205
|
+
|
|
206
|
+
def test_preview_namespace():
|
|
207
|
+
def get_estimators():
|
|
208
|
+
from sklearn.cluster import DBSCAN
|
|
209
|
+
from sklearn.decomposition import PCA
|
|
210
|
+
from sklearn.ensemble import RandomForestClassifier
|
|
211
|
+
from sklearn.linear_model import LinearRegression
|
|
212
|
+
from sklearn.svm import SVC
|
|
213
|
+
|
|
214
|
+
return (
|
|
215
|
+
LinearRegression(),
|
|
216
|
+
PCA(),
|
|
217
|
+
DBSCAN(),
|
|
218
|
+
SVC(),
|
|
219
|
+
RandomForestClassifier(),
|
|
220
|
+
)
|
|
221
|
+
|
|
222
|
+
from sklearnex.dispatcher import _is_preview_enabled
|
|
223
|
+
|
|
224
|
+
try:
|
|
225
|
+
sklearnex.patch_sklearn(preview=True)
|
|
226
|
+
|
|
227
|
+
assert _is_preview_enabled()
|
|
228
|
+
|
|
229
|
+
lr, pca, dbscan, svc, rfc = get_estimators()
|
|
230
|
+
assert "sklearnex" in rfc.__module__
|
|
231
|
+
|
|
232
|
+
if daal_check_version((2023, "P", 100)):
|
|
233
|
+
assert "sklearnex" in lr.__module__
|
|
234
|
+
else:
|
|
235
|
+
assert "daal4py" in lr.__module__
|
|
236
|
+
|
|
237
|
+
assert "sklearnex" in pca.__module__
|
|
238
|
+
assert "sklearnex" in dbscan.__module__
|
|
239
|
+
assert "sklearnex" in svc.__module__
|
|
240
|
+
|
|
241
|
+
finally:
|
|
242
|
+
sklearnex.unpatch_sklearn()
|
|
243
|
+
|
|
244
|
+
# no patching behavior
|
|
245
|
+
lr, pca, dbscan, svc, rfc = get_estimators()
|
|
246
|
+
assert "sklearn." in lr.__module__ and "daal4py" not in lr.__module__
|
|
247
|
+
assert "sklearn." in pca.__module__ and "daal4py" not in pca.__module__
|
|
248
|
+
assert "sklearn." in dbscan.__module__ and "daal4py" not in dbscan.__module__
|
|
249
|
+
assert "sklearn." in svc.__module__ and "daal4py" not in svc.__module__
|
|
250
|
+
assert "sklearn." in rfc.__module__ and "daal4py" not in rfc.__module__
|
|
251
|
+
|
|
252
|
+
# default patching behavior
|
|
253
|
+
try:
|
|
254
|
+
sklearnex.patch_sklearn()
|
|
255
|
+
assert not _is_preview_enabled()
|
|
256
|
+
|
|
257
|
+
lr, pca, dbscan, svc, rfc = get_estimators()
|
|
258
|
+
if daal_check_version((2023, "P", 100)):
|
|
259
|
+
assert "sklearnex" in lr.__module__
|
|
260
|
+
else:
|
|
261
|
+
assert "daal4py" in lr.__module__
|
|
262
|
+
|
|
263
|
+
assert "sklearnex" in pca.__module__
|
|
264
|
+
assert "sklearnex" in rfc.__module__
|
|
265
|
+
assert "sklearnex" in dbscan.__module__
|
|
266
|
+
assert "sklearnex" in svc.__module__
|
|
267
|
+
finally:
|
|
268
|
+
sklearnex.unpatch_sklearn()
|
scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/tests/test_n_jobs_support.py
ADDED
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# ==============================================================================
|
|
2
|
+
# Copyright 2023 Intel Corporation
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
# ==============================================================================
|
|
16
|
+
|
|
17
|
+
import inspect
|
|
18
|
+
import logging
|
|
19
|
+
from multiprocessing import cpu_count
|
|
20
|
+
|
|
21
|
+
import pytest
|
|
22
|
+
from sklearn.base import BaseEstimator
|
|
23
|
+
from sklearn.datasets import make_classification
|
|
24
|
+
|
|
25
|
+
from sklearnex.dispatcher import get_patch_map
|
|
26
|
+
from sklearnex.svm import SVC, NuSVC
|
|
27
|
+
|
|
28
|
+
ESTIMATORS = set(
|
|
29
|
+
filter(
|
|
30
|
+
lambda x: inspect.isclass(x) and issubclass(x, BaseEstimator),
|
|
31
|
+
[value[0][0][2] for value in get_patch_map().values()],
|
|
32
|
+
)
|
|
33
|
+
)
|
|
34
|
+
|
|
35
|
+
X, Y = make_classification(n_samples=40, n_features=4, random_state=42)
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
@pytest.mark.parametrize("estimator_class", ESTIMATORS)
|
|
39
|
+
@pytest.mark.parametrize("n_jobs", [None, -1, 1, 2])
|
|
40
|
+
def test_n_jobs_support(caplog, estimator_class, n_jobs):
|
|
41
|
+
def check_estimator_doc(estimator):
|
|
42
|
+
if estimator.__doc__ is not None:
|
|
43
|
+
assert "n_jobs" in estimator.__doc__
|
|
44
|
+
|
|
45
|
+
def check_n_jobs_entry_in_logs(caplog, function_name, n_jobs):
|
|
46
|
+
for rec in caplog.records:
|
|
47
|
+
if function_name in rec.message and "threads" in rec.message:
|
|
48
|
+
expected_n_jobs = n_jobs if n_jobs > 0 else cpu_count() + 1 + n_jobs
|
|
49
|
+
logging.info(f"{function_name}: setting {expected_n_jobs} threads")
|
|
50
|
+
if f"{function_name}: setting {expected_n_jobs} threads" in rec.message:
|
|
51
|
+
return True
|
|
52
|
+
# False if n_jobs is set and not found in logs
|
|
53
|
+
return n_jobs is None
|
|
54
|
+
|
|
55
|
+
def check_method(*args, method, caplog):
|
|
56
|
+
method(*args)
|
|
57
|
+
assert check_n_jobs_entry_in_logs(caplog, method.__name__, n_jobs)
|
|
58
|
+
|
|
59
|
+
def check_methods_decoration(estimator):
|
|
60
|
+
funcs = {
|
|
61
|
+
i: getattr(estimator, i)
|
|
62
|
+
for i in dir(estimator)
|
|
63
|
+
if hasattr(estimator, i) and callable(getattr(estimator, i))
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
for func_name, func in funcs.items():
|
|
67
|
+
assert hasattr(func, "__onedal_n_jobs_decorated__") == (
|
|
68
|
+
func_name in estimator._n_jobs_supported_onedal_methods
|
|
69
|
+
), f"{estimator}.{func_name} n_jobs decoration does not match {estimator} n_jobs supported methods"
|
|
70
|
+
|
|
71
|
+
caplog.set_level(logging.DEBUG, logger="sklearnex")
|
|
72
|
+
estimator_kwargs = {"n_jobs": n_jobs}
|
|
73
|
+
# by default, [Nu]SVC.predict_proba is restricted by @available_if decorator
|
|
74
|
+
if estimator_class in [SVC, NuSVC]:
|
|
75
|
+
estimator_kwargs["probability"] = True
|
|
76
|
+
estimator_instance = estimator_class(**estimator_kwargs)
|
|
77
|
+
# check `n_jobs` parameter doc entry
|
|
78
|
+
check_estimator_doc(estimator_class)
|
|
79
|
+
check_estimator_doc(estimator_instance)
|
|
80
|
+
# check `n_jobs` log entry for supported methods
|
|
81
|
+
# `fit` call is required before other methods
|
|
82
|
+
check_method(X, Y, method=estimator_instance.fit, caplog=caplog)
|
|
83
|
+
for method_name in estimator_instance._n_jobs_supported_onedal_methods:
|
|
84
|
+
if method_name == "fit":
|
|
85
|
+
continue
|
|
86
|
+
method = getattr(estimator_instance, method_name)
|
|
87
|
+
if len(inspect.signature(method).parameters) == 0:
|
|
88
|
+
check_method(method=method, caplog=caplog)
|
|
89
|
+
else:
|
|
90
|
+
check_method(X, method=method, caplog=caplog)
|
|
91
|
+
# check if correct methods were decorated
|
|
92
|
+
check_methods_decoration(estimator_class)
|
|
93
|
+
check_methods_decoration(estimator_instance)
|
|
@@ -15,13 +15,7 @@
|
|
|
15
15
|
# ==============================================================================
|
|
16
16
|
import pytest
|
|
17
17
|
|
|
18
|
-
from sklearnex import config_context
|
|
19
|
-
|
|
20
|
-
patch_sklearn()
|
|
21
|
-
|
|
22
|
-
from sklearn.datasets import make_classification
|
|
23
|
-
from sklearn.ensemble import BaggingClassifier
|
|
24
|
-
from sklearn.svm import SVC
|
|
18
|
+
from sklearnex import config_context
|
|
25
19
|
|
|
26
20
|
try:
|
|
27
21
|
import dpctl
|
|
@@ -38,7 +32,11 @@ except (ImportError, ModuleNotFoundError):
|
|
|
38
32
|
"to see raised 'SyclQueueCreationError'. "
|
|
39
33
|
"'dpctl' module is required for test.",
|
|
40
34
|
)
|
|
41
|
-
def test_config_context_in_parallel():
|
|
35
|
+
def test_config_context_in_parallel(with_sklearnex):
|
|
36
|
+
from sklearn.datasets import make_classification
|
|
37
|
+
from sklearn.ensemble import BaggingClassifier
|
|
38
|
+
from sklearn.svm import SVC
|
|
39
|
+
|
|
42
40
|
x, y = make_classification(random_state=42)
|
|
43
41
|
try:
|
|
44
42
|
with config_context(target_offload="gpu", allow_fallback_to_host=False):
|