scikit-learn-intelex 2023.2.1__py38-none-win_amd64.whl → 2024.0.1__py38-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-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/__init__.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/__main__.py +16 -12
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/_config.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/_device_offload.py +90 -56
- scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/_utils.py +95 -0
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/basic_statistics/__init__.py +3 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/basic_statistics/basic_statistics.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/cluster/__init__.py +4 -4
- scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/cluster/dbscan.py +187 -0
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/cluster/k_means.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/cluster/tests/test_dbscan.py +12 -6
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/cluster/tests/test_kmeans.py +5 -5
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/decomposition/__init__.py +3 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/decomposition/pca.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/decomposition/tests/test_pca.py +5 -4
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/dispatcher.py +102 -72
- {scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview → scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex}/ensemble/__init__.py +12 -4
- scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/ensemble/_forest.py +1947 -0
- scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/ensemble/tests/test_forest.py +118 -0
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/glob/__main__.py +31 -16
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/glob/dispatcher.py +21 -14
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/linear_model/__init__.py +10 -10
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/linear_model/coordinate_descent.py +2 -2
- {scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview → scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex}/linear_model/linear.py +173 -83
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/linear_model/logistic_path.py +3 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/linear_model/ridge.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/linear_model/tests/test_linear.py +23 -7
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/linear_model/tests/test_logreg.py +4 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/manifold/__init__.py +3 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/manifold/t_sne.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/manifold/tests/test_tsne.py +4 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/metrics/__init__.py +5 -5
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/metrics/pairwise.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/metrics/ranking.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/metrics/tests/test_metrics.py +8 -6
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/model_selection/__init__.py +3 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/model_selection/split.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/model_selection/tests/test_model_selection.py +6 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/neighbors/__init__.py +9 -5
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/neighbors/common.py +100 -77
- scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/neighbors/knn_classification.py +331 -0
- scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/neighbors/knn_regression.py +307 -0
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/neighbors/knn_unsupervised.py +116 -58
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/neighbors/lof.py +118 -56
- scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/neighbors/tests/test_neighbors.py +85 -0
- {scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/decomposition → scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/preview}/__init__.py +18 -20
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/preview/cluster/__init__.py +3 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/preview/cluster/_common.py +7 -7
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/preview/cluster/k_means.py +104 -73
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/linear_model/linear.py → scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/preview/decomposition/__init__.py +4 -1
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/preview/decomposition/pca.py +128 -100
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/linear_model/tests/test_preview_linear.py → scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/preview/decomposition/tests/test_preview_pca.py +18 -16
- {scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/linear_model → scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/spmd}/__init__.py +24 -22
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/spmd/basic_statistics/__init__.py +3 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/spmd/basic_statistics/basic_statistics.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/spmd/cluster/__init__.py +11 -5
- scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/spmd/cluster/dbscan.py +50 -0
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/spmd/cluster/kmeans.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/spmd/decomposition/__init__.py +3 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/spmd/decomposition/pca.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/spmd/ensemble/__init__.py +3 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/spmd/ensemble/forest.py +16 -14
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/__init__.py +3 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/linear_model.py +2 -2
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/spmd/neighbors/__init__.py +3 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/spmd/neighbors/neighbors.py +3 -3
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/svm/__init__.py +11 -8
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/svm/_common.py +56 -56
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/svm/nusvc.py +110 -55
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/svm/nusvr.py +65 -31
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/svm/svc.py +136 -78
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/svm/svr.py +65 -31
- scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/svm/tests/test_svm.py +102 -0
- scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/tests/_models_info.py +170 -0
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/tests/test_config.py +9 -8
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/tests/test_memory_usage.py +63 -69
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/tests/test_monkeypatch.py +55 -53
- scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/tests/test_parallel.py +50 -0
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/tests/test_patching.py +8 -7
- scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability_tests.py +428 -0
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/tests/utils/_launch_algorithms.py +39 -39
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/utils/__init__.py +3 -3
- scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/utils/parallel.py +59 -0
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/utils/validation.py +2 -2
- {scikit_learn_intelex-2023.2.1.dist-info → scikit_learn_intelex-2024.0.1.dist-info}/METADATA +34 -35
- scikit_learn_intelex-2024.0.1.dist-info/RECORD +90 -0
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/_utils.py +0 -82
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/cluster/dbscan.py +0 -18
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/ensemble/__init__.py +0 -20
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/ensemble/forest.py +0 -18
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/ensemble/tests/test_forest.py +0 -46
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/neighbors/knn_classification.py +0 -228
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/neighbors/knn_regression.py +0 -213
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/neighbors/tests/test_neighbors.py +0 -57
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/__init__.py +0 -18
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/decomposition/tests/test_preview_pca.py +0 -28
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/ensemble/extra_trees.py +0 -1261
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/ensemble/forest.py +0 -1155
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/ensemble/tests/test_preview_ensemble.py +0 -67
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/linear_model/_common.py +0 -66
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/spmd/__init__.py +0 -23
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/svm/tests/test_svm.py +0 -63
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/tests/_models_info.py +0 -159
- scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability_tests.py +0 -383
- scikit_learn_intelex-2023.2.1.dist-info/RECORD +0 -95
- {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/doc/third-party-programs.txt +0 -0
- {scikit_learn_intelex-2023.2.1.dist-info → scikit_learn_intelex-2024.0.1.dist-info}/LICENSE.txt +0 -0
- {scikit_learn_intelex-2023.2.1.dist-info → scikit_learn_intelex-2024.0.1.dist-info}/WHEEL +0 -0
- {scikit_learn_intelex-2023.2.1.dist-info → scikit_learn_intelex-2024.0.1.dist-info}/top_level.txt +0 -0
|
@@ -0,0 +1,170 @@
|
|
|
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 numpy as np
|
|
18
|
+
from sklearn.cluster import DBSCAN, KMeans
|
|
19
|
+
from sklearn.decomposition import PCA
|
|
20
|
+
from sklearn.ensemble import RandomForestClassifier, RandomForestRegressor
|
|
21
|
+
from sklearn.linear_model import (
|
|
22
|
+
ElasticNet,
|
|
23
|
+
Lasso,
|
|
24
|
+
LinearRegression,
|
|
25
|
+
LogisticRegression,
|
|
26
|
+
LogisticRegressionCV,
|
|
27
|
+
Ridge,
|
|
28
|
+
)
|
|
29
|
+
from sklearn.manifold import TSNE
|
|
30
|
+
from sklearn.neighbors import (
|
|
31
|
+
KNeighborsClassifier,
|
|
32
|
+
KNeighborsRegressor,
|
|
33
|
+
LocalOutlierFactor,
|
|
34
|
+
NearestNeighbors,
|
|
35
|
+
)
|
|
36
|
+
from sklearn.svm import SVC
|
|
37
|
+
|
|
38
|
+
MODELS_INFO = [
|
|
39
|
+
{
|
|
40
|
+
"model": KNeighborsClassifier(algorithm="brute"),
|
|
41
|
+
"methods": ["kneighbors", "predict", "predict_proba", "score"],
|
|
42
|
+
"dataset": "classifier",
|
|
43
|
+
},
|
|
44
|
+
{
|
|
45
|
+
"model": KNeighborsRegressor(algorithm="brute"),
|
|
46
|
+
"methods": ["kneighbors", "predict", "score"],
|
|
47
|
+
"dataset": "regression",
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
"model": NearestNeighbors(algorithm="brute"),
|
|
51
|
+
"methods": ["kneighbors"],
|
|
52
|
+
"dataset": "blobs",
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"model": LocalOutlierFactor(novelty=False),
|
|
56
|
+
"methods": ["fit_predict"],
|
|
57
|
+
"dataset": "blobs",
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"model": LocalOutlierFactor(novelty=True),
|
|
61
|
+
"methods": ["predict"],
|
|
62
|
+
"dataset": "blobs",
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"model": DBSCAN(),
|
|
66
|
+
"methods": ["fit_predict"],
|
|
67
|
+
"dataset": "blobs",
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"model": SVC(probability=True),
|
|
71
|
+
"methods": ["decision_function", "predict", "predict_proba", "score"],
|
|
72
|
+
"dataset": "classifier",
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"model": KMeans(),
|
|
76
|
+
"methods": ["fit_predict", "fit_transform", "transform", "predict", "score"],
|
|
77
|
+
"dataset": "blobs",
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
"model": ElasticNet(),
|
|
81
|
+
"methods": ["predict", "score"],
|
|
82
|
+
"dataset": "regression",
|
|
83
|
+
},
|
|
84
|
+
{
|
|
85
|
+
"model": Lasso(),
|
|
86
|
+
"methods": ["predict", "score"],
|
|
87
|
+
"dataset": "regression",
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"model": PCA(),
|
|
91
|
+
"methods": ["fit_transform", "transform", "score"],
|
|
92
|
+
"dataset": "classifier",
|
|
93
|
+
},
|
|
94
|
+
{
|
|
95
|
+
"model": LogisticRegression(max_iter=100, multi_class="multinomial"),
|
|
96
|
+
"methods": [
|
|
97
|
+
"decision_function",
|
|
98
|
+
"predict",
|
|
99
|
+
"predict_proba",
|
|
100
|
+
"predict_log_proba",
|
|
101
|
+
"score",
|
|
102
|
+
],
|
|
103
|
+
"dataset": "classifier",
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"model": LogisticRegressionCV(max_iter=100),
|
|
107
|
+
"methods": [
|
|
108
|
+
"decision_function",
|
|
109
|
+
"predict",
|
|
110
|
+
"predict_proba",
|
|
111
|
+
"predict_log_proba",
|
|
112
|
+
"score",
|
|
113
|
+
],
|
|
114
|
+
"dataset": "classifier",
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
"model": RandomForestClassifier(n_estimators=10),
|
|
118
|
+
"methods": ["predict", "predict_proba", "predict_log_proba", "score"],
|
|
119
|
+
"dataset": "classifier",
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
"model": RandomForestRegressor(n_estimators=10),
|
|
123
|
+
"methods": ["predict", "score"],
|
|
124
|
+
"dataset": "regression",
|
|
125
|
+
},
|
|
126
|
+
{
|
|
127
|
+
"model": LinearRegression(),
|
|
128
|
+
"methods": ["predict", "score"],
|
|
129
|
+
"dataset": "regression",
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"model": Ridge(),
|
|
133
|
+
"methods": ["predict", "score"],
|
|
134
|
+
"dataset": "regression",
|
|
135
|
+
},
|
|
136
|
+
]
|
|
137
|
+
|
|
138
|
+
TYPES = [
|
|
139
|
+
np.int8,
|
|
140
|
+
np.int16,
|
|
141
|
+
np.int32,
|
|
142
|
+
np.int64,
|
|
143
|
+
np.float16,
|
|
144
|
+
np.float32,
|
|
145
|
+
np.float64,
|
|
146
|
+
np.uint8,
|
|
147
|
+
np.uint16,
|
|
148
|
+
np.uint32,
|
|
149
|
+
np.uint64,
|
|
150
|
+
]
|
|
151
|
+
|
|
152
|
+
TO_SKIP = [
|
|
153
|
+
# --------------- NO INFO ---------------
|
|
154
|
+
r"KMeans .*transform",
|
|
155
|
+
r"KMeans .*score",
|
|
156
|
+
r"PCA .*score",
|
|
157
|
+
r"LogisticRegression .*decision_function",
|
|
158
|
+
r"LogisticRegressionCV .*decision_function",
|
|
159
|
+
r"LogisticRegressionCV .*predict",
|
|
160
|
+
r"LogisticRegressionCV .*predict_proba",
|
|
161
|
+
r"LogisticRegressionCV .*predict_log_proba",
|
|
162
|
+
r"LogisticRegressionCV .*score",
|
|
163
|
+
# --------------- Scikit ---------------
|
|
164
|
+
r"Ridge float16 predict",
|
|
165
|
+
r"Ridge float16 score",
|
|
166
|
+
r"RandomForestClassifier .*predict_proba",
|
|
167
|
+
r"RandomForestClassifier .*predict_log_proba",
|
|
168
|
+
r"pairwise_distances .*pairwise_distances", # except float64
|
|
169
|
+
r"roc_auc_score .*roc_auc_score",
|
|
170
|
+
]
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# ==============================================================================
|
|
2
2
|
# Copyright 2021 Intel Corporation
|
|
3
3
|
#
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -12,9 +12,10 @@
|
|
|
12
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
|
-
|
|
15
|
+
# ==============================================================================
|
|
16
16
|
|
|
17
17
|
import sklearn
|
|
18
|
+
|
|
18
19
|
import sklearnex
|
|
19
20
|
|
|
20
21
|
|
|
@@ -27,12 +28,12 @@ def test_get_config_contains_sklearn_params():
|
|
|
27
28
|
|
|
28
29
|
def test_set_config_works():
|
|
29
30
|
default_config = sklearnex.get_config()
|
|
30
|
-
sklearnex.set_config(
|
|
31
|
-
|
|
32
|
-
|
|
31
|
+
sklearnex.set_config(
|
|
32
|
+
assume_finite=True, target_offload="cpu:0", allow_fallback_to_host=True
|
|
33
|
+
)
|
|
33
34
|
|
|
34
35
|
config = sklearnex.get_config()
|
|
35
|
-
assert config[
|
|
36
|
-
assert config[
|
|
37
|
-
assert config[
|
|
36
|
+
assert config["target_offload"] == "cpu:0"
|
|
37
|
+
assert config["allow_fallback_to_host"]
|
|
38
|
+
assert config["assume_finite"]
|
|
38
39
|
sklearnex.set_config(**default_config)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# ==============================================================================
|
|
2
2
|
# Copyright 2021 Intel Corporation
|
|
3
3
|
#
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -12,31 +12,26 @@
|
|
|
12
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
|
-
|
|
15
|
+
# ==============================================================================
|
|
16
16
|
|
|
17
|
-
import
|
|
18
|
-
import
|
|
17
|
+
import gc
|
|
18
|
+
import logging
|
|
19
19
|
import tracemalloc
|
|
20
|
+
import types
|
|
21
|
+
|
|
22
|
+
import numpy as np
|
|
23
|
+
import pandas as pd
|
|
24
|
+
import pytest
|
|
25
|
+
from scipy.stats import pearsonr
|
|
26
|
+
from sklearn.base import BaseEstimator
|
|
27
|
+
from sklearn.datasets import make_classification
|
|
28
|
+
from sklearn.model_selection import KFold
|
|
29
|
+
|
|
20
30
|
from sklearnex import get_patch_map
|
|
21
|
-
from sklearnex.model_selection import train_test_split
|
|
22
|
-
from sklearnex.utils import _assert_all_finite
|
|
23
31
|
from sklearnex.metrics import pairwise_distances, roc_auc_score
|
|
32
|
+
from sklearnex.model_selection import train_test_split
|
|
24
33
|
from sklearnex.preview.decomposition import PCA as PreviewPCA
|
|
25
|
-
from sklearnex.
|
|
26
|
-
from sklearnex.preview.ensemble import (
|
|
27
|
-
RandomForestClassifier as PreviewRandomForestClassifier,
|
|
28
|
-
RandomForestRegressor as PreviewRandomForestRegressor,
|
|
29
|
-
ExtraTreesClassifier as PreviewExtraTreesClassifier,
|
|
30
|
-
ExtraTreesRegressor as PreviewExtraTreesRegressor
|
|
31
|
-
)
|
|
32
|
-
from sklearn.base import BaseEstimator
|
|
33
|
-
from sklearn.model_selection import KFold
|
|
34
|
-
from sklearn.datasets import make_classification
|
|
35
|
-
from scipy.stats import pearsonr
|
|
36
|
-
import pandas as pd
|
|
37
|
-
import numpy as np
|
|
38
|
-
import gc
|
|
39
|
-
import logging
|
|
34
|
+
from sklearnex.utils import _assert_all_finite
|
|
40
35
|
|
|
41
36
|
|
|
42
37
|
class TrainTestSplitEstimator:
|
|
@@ -63,12 +58,12 @@ class PairwiseDistancesEstimator:
|
|
|
63
58
|
|
|
64
59
|
class CosineDistancesEstimator(PairwiseDistancesEstimator):
|
|
65
60
|
def __init__(self):
|
|
66
|
-
self.metric =
|
|
61
|
+
self.metric = "cosine"
|
|
67
62
|
|
|
68
63
|
|
|
69
64
|
class CorrelationDistancesEstimator(PairwiseDistancesEstimator):
|
|
70
65
|
def __init__(self):
|
|
71
|
-
self.metric =
|
|
66
|
+
self.metric = "correlation"
|
|
72
67
|
|
|
73
68
|
|
|
74
69
|
class RocAucEstimator:
|
|
@@ -86,35 +81,30 @@ def get_patched_estimators(ban_list, output_list):
|
|
|
86
81
|
estimator, name = listing[0][0][2], listing[0][0][1]
|
|
87
82
|
if not isinstance(estimator, types.FunctionType):
|
|
88
83
|
if name not in ban_list:
|
|
89
|
-
if
|
|
90
|
-
if hasattr(estimator,
|
|
84
|
+
if issubclass(estimator, BaseEstimator):
|
|
85
|
+
if hasattr(estimator, "fit"):
|
|
91
86
|
output_list.append(estimator)
|
|
92
87
|
|
|
93
88
|
|
|
94
89
|
def remove_duplicated_estimators(estimators_list):
|
|
95
90
|
estimators_map = {}
|
|
96
91
|
for estimator in estimators_list:
|
|
97
|
-
full_name = f
|
|
92
|
+
full_name = f"{estimator.__module__}.{estimator.__name__}"
|
|
98
93
|
estimators_map[full_name] = estimator
|
|
99
94
|
return estimators_map.values()
|
|
100
95
|
|
|
101
96
|
|
|
102
97
|
BANNED_ESTIMATORS = (
|
|
103
|
-
|
|
104
|
-
|
|
98
|
+
"LocalOutlierFactor", # fails on ndarray_c for sklearn > 1.0
|
|
99
|
+
"TSNE", # too slow for using in testing on common data size
|
|
105
100
|
)
|
|
106
101
|
estimators = [
|
|
107
102
|
PreviewPCA,
|
|
108
|
-
PreviewLinearRegression,
|
|
109
|
-
PreviewRandomForestClassifier,
|
|
110
|
-
PreviewRandomForestRegressor,
|
|
111
|
-
PreviewExtraTreesClassifier,
|
|
112
|
-
PreviewExtraTreesRegressor,
|
|
113
103
|
TrainTestSplitEstimator,
|
|
114
104
|
FiniteCheckEstimator,
|
|
115
105
|
CosineDistancesEstimator,
|
|
116
106
|
CorrelationDistancesEstimator,
|
|
117
|
-
RocAucEstimator
|
|
107
|
+
RocAucEstimator,
|
|
118
108
|
]
|
|
119
109
|
get_patched_estimators(BANNED_ESTIMATORS, estimators)
|
|
120
110
|
estimators = remove_duplicated_estimators(estimators)
|
|
@@ -136,17 +126,9 @@ def dataframe_f(x, y):
|
|
|
136
126
|
return pd.DataFrame(np.asfortranarray(x)), pd.Series(y)
|
|
137
127
|
|
|
138
128
|
|
|
139
|
-
data_transforms = [
|
|
140
|
-
ndarray_c,
|
|
141
|
-
ndarray_f,
|
|
142
|
-
dataframe_c,
|
|
143
|
-
dataframe_f
|
|
144
|
-
]
|
|
129
|
+
data_transforms = [ndarray_c, ndarray_f, dataframe_c, dataframe_f]
|
|
145
130
|
|
|
146
|
-
data_shapes = [
|
|
147
|
-
(1000, 100),
|
|
148
|
-
(2000, 50)
|
|
149
|
-
]
|
|
131
|
+
data_shapes = [(1000, 100), (2000, 50)]
|
|
150
132
|
|
|
151
133
|
EXTRA_MEMORY_THRESHOLD = 0.15
|
|
152
134
|
N_SPLITS = 10
|
|
@@ -154,9 +136,13 @@ N_SPLITS = 10
|
|
|
154
136
|
|
|
155
137
|
def gen_clsf_data(n_samples, n_features):
|
|
156
138
|
data, label = make_classification(
|
|
157
|
-
n_classes=2, n_samples=n_samples, n_features=n_features, random_state=777
|
|
158
|
-
|
|
159
|
-
|
|
139
|
+
n_classes=2, n_samples=n_samples, n_features=n_features, random_state=777
|
|
140
|
+
)
|
|
141
|
+
return (
|
|
142
|
+
data,
|
|
143
|
+
label,
|
|
144
|
+
data.size * data.dtype.itemsize + label.size * label.dtype.itemsize,
|
|
145
|
+
)
|
|
160
146
|
|
|
161
147
|
|
|
162
148
|
def split_train_inference(kf, x, y, estimator):
|
|
@@ -172,11 +158,11 @@ def split_train_inference(kf, x, y, estimator):
|
|
|
172
158
|
# fallback to stock scikit-learn with default parameters
|
|
173
159
|
alg = estimator()
|
|
174
160
|
alg.fit(x_train, y_train)
|
|
175
|
-
if hasattr(alg,
|
|
161
|
+
if hasattr(alg, "predict"):
|
|
176
162
|
alg.predict(x_test)
|
|
177
|
-
elif hasattr(alg,
|
|
163
|
+
elif hasattr(alg, "transform"):
|
|
178
164
|
alg.transform(x_test)
|
|
179
|
-
elif hasattr(alg,
|
|
165
|
+
elif hasattr(alg, "kneighbors"):
|
|
180
166
|
alg.kneighbors(x_test)
|
|
181
167
|
del alg, x_train, x_test, y_train, y_test
|
|
182
168
|
mem_tracks.append(tracemalloc.get_traced_memory()[0])
|
|
@@ -194,38 +180,46 @@ def _kfold_function_template(estimator, data_transform_function, data_shape):
|
|
|
194
180
|
|
|
195
181
|
mem_before, _ = tracemalloc.get_traced_memory()
|
|
196
182
|
mem_tracks = split_train_inference(kf, x, y, estimator)
|
|
197
|
-
mem_iter_diffs =
|
|
183
|
+
mem_iter_diffs = np.array(mem_tracks[1:]) - np.array(mem_tracks[:-1])
|
|
198
184
|
mem_incr_mean, mem_incr_std = mem_iter_diffs.mean(), mem_iter_diffs.std()
|
|
199
185
|
mem_incr_mean, mem_incr_std = round(mem_incr_mean), round(mem_incr_std)
|
|
200
186
|
mem_iter_corr, _ = pearsonr(mem_tracks, list(range(len(mem_tracks))))
|
|
201
187
|
if mem_iter_corr > 0.95:
|
|
202
|
-
logging.warning(
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
188
|
+
logging.warning(
|
|
189
|
+
"Memory usage is steadily increasing with iterations "
|
|
190
|
+
"(Pearson correlation coefficient between "
|
|
191
|
+
f"memory tracks and iterations is {mem_iter_corr})\n"
|
|
192
|
+
"Memory usage increase per iteration: "
|
|
193
|
+
f"{mem_incr_mean}±{mem_incr_std} bytes"
|
|
194
|
+
)
|
|
207
195
|
mem_before_gc, _ = tracemalloc.get_traced_memory()
|
|
208
196
|
mem_diff = mem_before_gc - mem_before
|
|
209
|
-
message =
|
|
210
|
-
|
|
211
|
-
f
|
|
212
|
-
f
|
|
213
|
-
|
|
214
|
-
|
|
197
|
+
message = (
|
|
198
|
+
"Size of extra allocated memory {} using garbage collector "
|
|
199
|
+
f"is greater than {EXTRA_MEMORY_THRESHOLD * 100}% of input data"
|
|
200
|
+
f"\n\tAlgorithm: {estimator.__name__}"
|
|
201
|
+
f"\n\tInput data size: {data_memory_size} bytes"
|
|
202
|
+
"\n\tExtra allocated memory size: {} bytes"
|
|
203
|
+
" / {} %"
|
|
204
|
+
)
|
|
215
205
|
if mem_diff >= EXTRA_MEMORY_THRESHOLD * data_memory_size:
|
|
216
|
-
logging.warning(
|
|
217
|
-
|
|
206
|
+
logging.warning(
|
|
207
|
+
message.format(
|
|
208
|
+
"before", mem_diff, round((mem_diff) / data_memory_size * 100, 2)
|
|
209
|
+
)
|
|
210
|
+
)
|
|
218
211
|
gc.collect()
|
|
219
212
|
mem_after, _ = tracemalloc.get_traced_memory()
|
|
220
213
|
tracemalloc.stop()
|
|
221
214
|
mem_diff = mem_after - mem_before
|
|
222
215
|
|
|
223
|
-
assert mem_diff < EXTRA_MEMORY_THRESHOLD * data_memory_size,
|
|
224
|
-
|
|
216
|
+
assert mem_diff < EXTRA_MEMORY_THRESHOLD * data_memory_size, message.format(
|
|
217
|
+
"after", mem_diff, round((mem_diff) / data_memory_size * 100, 2)
|
|
218
|
+
)
|
|
225
219
|
|
|
226
220
|
|
|
227
|
-
@pytest.mark.parametrize(
|
|
228
|
-
@pytest.mark.parametrize(
|
|
229
|
-
@pytest.mark.parametrize(
|
|
221
|
+
@pytest.mark.parametrize("data_transform_function", data_transforms)
|
|
222
|
+
@pytest.mark.parametrize("estimator", estimators)
|
|
223
|
+
@pytest.mark.parametrize("data_shape", data_shapes)
|
|
230
224
|
def test_memory_leaks(estimator, data_transform_function, data_shape):
|
|
231
225
|
_kfold_function_template(estimator, data_transform_function, data_shape)
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
# ===============================================================================
|
|
2
2
|
# Copyright 2021 Intel Corporation
|
|
3
3
|
#
|
|
4
4
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
13
|
# See the License for the specific language governing permissions and
|
|
14
14
|
# limitations under the License.
|
|
15
|
-
|
|
15
|
+
# ===============================================================================
|
|
16
16
|
|
|
17
17
|
import sklearnex
|
|
18
18
|
from daal4py.sklearn._utils import daal_check_version
|
|
@@ -35,9 +35,9 @@ def test_monkey_patching():
|
|
|
35
35
|
n = _classes[i][1]
|
|
36
36
|
|
|
37
37
|
class_module = getattr(p, n).__module__
|
|
38
|
-
assert
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
assert class_module.startswith("daal4py") or class_module.startswith(
|
|
39
|
+
"sklearnex"
|
|
40
|
+
), "Patching has completed with error."
|
|
41
41
|
|
|
42
42
|
for i, _ in enumerate(_tokens):
|
|
43
43
|
t = _tokens[i]
|
|
@@ -46,8 +46,7 @@ def test_monkey_patching():
|
|
|
46
46
|
|
|
47
47
|
sklearnex.unpatch_sklearn(t)
|
|
48
48
|
class_module = getattr(p, n).__module__
|
|
49
|
-
assert class_module.startswith(
|
|
50
|
-
"Unpatching has completed with error."
|
|
49
|
+
assert class_module.startswith("sklearn"), "Unpatching has completed with error."
|
|
51
50
|
|
|
52
51
|
sklearnex.unpatch_sklearn()
|
|
53
52
|
|
|
@@ -57,8 +56,7 @@ def test_monkey_patching():
|
|
|
57
56
|
n = _classes[i][1]
|
|
58
57
|
|
|
59
58
|
class_module = getattr(p, n).__module__
|
|
60
|
-
assert class_module.startswith(
|
|
61
|
-
"Unpatching has completed with error."
|
|
59
|
+
assert class_module.startswith("sklearn"), "Unpatching has completed with error."
|
|
62
60
|
|
|
63
61
|
sklearnex.unpatch_sklearn()
|
|
64
62
|
|
|
@@ -70,9 +68,9 @@ def test_monkey_patching():
|
|
|
70
68
|
sklearnex.patch_sklearn(t)
|
|
71
69
|
|
|
72
70
|
class_module = getattr(p, n).__module__
|
|
73
|
-
assert
|
|
74
|
-
|
|
75
|
-
|
|
71
|
+
assert class_module.startswith("daal4py") or class_module.startswith(
|
|
72
|
+
"sklearnex"
|
|
73
|
+
), "Patching has completed with error."
|
|
76
74
|
|
|
77
75
|
sklearnex.unpatch_sklearn()
|
|
78
76
|
|
|
@@ -81,14 +79,14 @@ def test_patch_by_list_simple():
|
|
|
81
79
|
sklearnex.patch_sklearn(["LogisticRegression"])
|
|
82
80
|
|
|
83
81
|
from sklearn.ensemble import RandomForestRegressor
|
|
84
|
-
from sklearn.neighbors import KNeighborsRegressor
|
|
85
82
|
from sklearn.linear_model import LogisticRegression
|
|
83
|
+
from sklearn.neighbors import KNeighborsRegressor
|
|
86
84
|
from sklearn.svm import SVC
|
|
87
85
|
|
|
88
|
-
assert RandomForestRegressor.__module__.startswith(
|
|
89
|
-
assert KNeighborsRegressor.__module__.startswith(
|
|
90
|
-
assert LogisticRegression.__module__.startswith(
|
|
91
|
-
assert SVC.__module__.startswith(
|
|
86
|
+
assert RandomForestRegressor.__module__.startswith("sklearn")
|
|
87
|
+
assert KNeighborsRegressor.__module__.startswith("sklearn")
|
|
88
|
+
assert LogisticRegression.__module__.startswith("daal4py")
|
|
89
|
+
assert SVC.__module__.startswith("sklearn")
|
|
92
90
|
|
|
93
91
|
sklearnex.unpatch_sklearn()
|
|
94
92
|
|
|
@@ -97,14 +95,14 @@ def test_patch_by_list_many_estimators():
|
|
|
97
95
|
sklearnex.patch_sklearn(["LogisticRegression", "SVC"])
|
|
98
96
|
|
|
99
97
|
from sklearn.ensemble import RandomForestRegressor
|
|
100
|
-
from sklearn.neighbors import KNeighborsRegressor
|
|
101
98
|
from sklearn.linear_model import LogisticRegression
|
|
99
|
+
from sklearn.neighbors import KNeighborsRegressor
|
|
102
100
|
from sklearn.svm import SVC
|
|
103
101
|
|
|
104
|
-
assert RandomForestRegressor.__module__.startswith(
|
|
105
|
-
assert KNeighborsRegressor.__module__.startswith(
|
|
106
|
-
assert LogisticRegression.__module__.startswith(
|
|
107
|
-
assert SVC.__module__.startswith(
|
|
102
|
+
assert RandomForestRegressor.__module__.startswith("sklearn")
|
|
103
|
+
assert KNeighborsRegressor.__module__.startswith("sklearn")
|
|
104
|
+
assert LogisticRegression.__module__.startswith("daal4py")
|
|
105
|
+
assert SVC.__module__.startswith("daal4py") or SVC.__module__.startswith("sklearnex")
|
|
108
106
|
|
|
109
107
|
sklearnex.unpatch_sklearn()
|
|
110
108
|
|
|
@@ -113,31 +111,32 @@ def test_unpatch_by_list_many_estimators():
|
|
|
113
111
|
sklearnex.patch_sklearn()
|
|
114
112
|
|
|
115
113
|
from sklearn.ensemble import RandomForestRegressor
|
|
116
|
-
from sklearn.neighbors import KNeighborsRegressor
|
|
117
114
|
from sklearn.linear_model import LogisticRegression
|
|
115
|
+
from sklearn.neighbors import KNeighborsRegressor
|
|
118
116
|
from sklearn.svm import SVC
|
|
119
117
|
|
|
120
|
-
assert RandomForestRegressor.__module__.startswith(
|
|
121
|
-
assert KNeighborsRegressor.__module__.startswith(
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
assert
|
|
118
|
+
assert RandomForestRegressor.__module__.startswith("sklearnex")
|
|
119
|
+
assert KNeighborsRegressor.__module__.startswith(
|
|
120
|
+
"daal4py"
|
|
121
|
+
) or KNeighborsRegressor.__module__.startswith("sklearnex")
|
|
122
|
+
assert LogisticRegression.__module__.startswith("daal4py")
|
|
123
|
+
assert SVC.__module__.startswith("daal4py") or SVC.__module__.startswith("sklearnex")
|
|
125
124
|
|
|
126
125
|
sklearnex.unpatch_sklearn(["KNeighborsRegressor", "RandomForestRegressor"])
|
|
127
126
|
|
|
128
127
|
from sklearn.ensemble import RandomForestRegressor
|
|
129
|
-
from sklearn.neighbors import KNeighborsRegressor
|
|
130
128
|
from sklearn.linear_model import LogisticRegression
|
|
129
|
+
from sklearn.neighbors import KNeighborsRegressor
|
|
131
130
|
from sklearn.svm import SVC
|
|
132
131
|
|
|
133
|
-
assert RandomForestRegressor.__module__.startswith(
|
|
134
|
-
assert KNeighborsRegressor.__module__.startswith(
|
|
135
|
-
assert LogisticRegression.__module__.startswith(
|
|
136
|
-
assert SVC.__module__.startswith(
|
|
132
|
+
assert RandomForestRegressor.__module__.startswith("sklearn")
|
|
133
|
+
assert KNeighborsRegressor.__module__.startswith("sklearn")
|
|
134
|
+
assert LogisticRegression.__module__.startswith("daal4py")
|
|
135
|
+
assert SVC.__module__.startswith("daal4py") or SVC.__module__.startswith("sklearnex")
|
|
137
136
|
|
|
138
137
|
|
|
139
138
|
def test_patching_checker():
|
|
140
|
-
for name in [None,
|
|
139
|
+
for name in [None, "SVC", "PCA"]:
|
|
141
140
|
sklearnex.patch_sklearn(name=name)
|
|
142
141
|
assert sklearnex.sklearn_is_patched(name=name)
|
|
143
142
|
|
|
@@ -159,10 +158,10 @@ def test_patching_checker():
|
|
|
159
158
|
|
|
160
159
|
def test_preview_namespace():
|
|
161
160
|
def get_estimators():
|
|
161
|
+
from sklearn.cluster import DBSCAN
|
|
162
|
+
from sklearn.decomposition import PCA
|
|
162
163
|
from sklearn.ensemble import RandomForestClassifier
|
|
163
164
|
from sklearn.linear_model import LinearRegression
|
|
164
|
-
from sklearn.decomposition import PCA
|
|
165
|
-
from sklearn.cluster import DBSCAN
|
|
166
165
|
from sklearn.svm import SVC
|
|
167
166
|
|
|
168
167
|
return LinearRegression(), PCA(), DBSCAN(), SVC(), RandomForestClassifier()
|
|
@@ -175,34 +174,37 @@ def test_preview_namespace():
|
|
|
175
174
|
assert sklearnex.dispatcher._is_preview_enabled()
|
|
176
175
|
|
|
177
176
|
lr, pca, dbscan, svc, rfc = get_estimators()
|
|
178
|
-
assert
|
|
177
|
+
assert "sklearnex" in rfc.__module__
|
|
179
178
|
|
|
180
|
-
if daal_check_version((2023,
|
|
181
|
-
assert
|
|
179
|
+
if daal_check_version((2023, "P", 100)):
|
|
180
|
+
assert "sklearnex" in lr.__module__
|
|
182
181
|
else:
|
|
183
|
-
assert
|
|
182
|
+
assert "daal4py" in lr.__module__
|
|
184
183
|
|
|
185
|
-
assert
|
|
186
|
-
assert
|
|
187
|
-
assert
|
|
184
|
+
assert "sklearnex.preview" in pca.__module__
|
|
185
|
+
assert "sklearnex" in dbscan.__module__
|
|
186
|
+
assert "sklearnex" in svc.__module__
|
|
188
187
|
sklearnex.unpatch_sklearn()
|
|
189
188
|
|
|
190
189
|
# no patching behavior
|
|
191
190
|
lr, pca, dbscan, svc, rfc = get_estimators()
|
|
192
|
-
assert
|
|
193
|
-
assert
|
|
194
|
-
assert
|
|
195
|
-
assert
|
|
196
|
-
assert
|
|
191
|
+
assert "sklearn." in lr.__module__
|
|
192
|
+
assert "sklearn." in pca.__module__
|
|
193
|
+
assert "sklearn." in dbscan.__module__
|
|
194
|
+
assert "sklearn." in svc.__module__
|
|
195
|
+
assert "sklearn." in rfc.__module__
|
|
197
196
|
|
|
198
197
|
# default patching behavior
|
|
199
198
|
sklearnex.patch_sklearn()
|
|
200
199
|
assert not sklearnex.dispatcher._is_preview_enabled()
|
|
201
200
|
|
|
202
201
|
lr, pca, dbscan, svc, rfc = get_estimators()
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
assert
|
|
202
|
+
if daal_check_version((2023, "P", 100)):
|
|
203
|
+
assert "sklearnex" in lr.__module__
|
|
204
|
+
else:
|
|
205
|
+
assert "daal4py" in lr.__module__
|
|
206
|
+
assert "daal4py" in pca.__module__
|
|
207
|
+
assert "sklearnex" in rfc.__module__
|
|
208
|
+
assert "sklearnex" in dbscan.__module__
|
|
209
|
+
assert "sklearnex" in svc.__module__
|
|
208
210
|
sklearnex.unpatch_sklearn()
|