scikit-learn-intelex 2023.2.1__py39-none-win_amd64.whl → 2024.0.1__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-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
scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/ensemble/tests/test_forest.py
ADDED
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
#!/usr/bin/env python
|
|
2
|
+
# ===============================================================================
|
|
3
|
+
# Copyright 2023 Intel Corporation
|
|
4
|
+
#
|
|
5
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
6
|
+
# you may not use this file except in compliance with the License.
|
|
7
|
+
# You may obtain a copy of the License at
|
|
8
|
+
#
|
|
9
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
10
|
+
#
|
|
11
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
12
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
13
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
|
+
# See the License for the specific language governing permissions and
|
|
15
|
+
# limitations under the License.
|
|
16
|
+
# ===============================================================================
|
|
17
|
+
|
|
18
|
+
import pytest
|
|
19
|
+
from numpy.testing import assert_allclose
|
|
20
|
+
from sklearn.datasets import make_classification, make_regression
|
|
21
|
+
|
|
22
|
+
from daal4py.sklearn._utils import daal_check_version
|
|
23
|
+
from onedal.tests.utils._dataframes_support import (
|
|
24
|
+
_as_numpy,
|
|
25
|
+
_convert_to_dataframe,
|
|
26
|
+
get_dataframes_and_queues,
|
|
27
|
+
)
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
|
|
31
|
+
def test_sklearnex_import_rf_classifier(dataframe, queue):
|
|
32
|
+
from sklearnex.ensemble import RandomForestClassifier
|
|
33
|
+
|
|
34
|
+
X, y = make_classification(
|
|
35
|
+
n_samples=1000,
|
|
36
|
+
n_features=4,
|
|
37
|
+
n_informative=2,
|
|
38
|
+
n_redundant=0,
|
|
39
|
+
random_state=0,
|
|
40
|
+
shuffle=False,
|
|
41
|
+
)
|
|
42
|
+
X = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
|
|
43
|
+
y = _convert_to_dataframe(y, sycl_queue=queue, target_df=dataframe)
|
|
44
|
+
rf = RandomForestClassifier(max_depth=2, random_state=0).fit(X, y)
|
|
45
|
+
assert "sklearnex" in rf.__module__
|
|
46
|
+
assert_allclose([1], _as_numpy(rf.predict([[0, 0, 0, 0]])))
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
# TODO:
|
|
50
|
+
# investigate failure for `dpnp.ndarrays` and `dpctl.tensors` on `GPU`
|
|
51
|
+
@pytest.mark.parametrize(
|
|
52
|
+
"dataframe,queue", get_dataframes_and_queues(device_filter_="cpu")
|
|
53
|
+
)
|
|
54
|
+
def test_sklearnex_import_rf_regression(dataframe, queue):
|
|
55
|
+
from sklearnex.ensemble import RandomForestRegressor
|
|
56
|
+
|
|
57
|
+
X, y = make_regression(n_features=4, n_informative=2, random_state=0, shuffle=False)
|
|
58
|
+
X = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
|
|
59
|
+
y = _convert_to_dataframe(y, sycl_queue=queue, target_df=dataframe)
|
|
60
|
+
rf = RandomForestRegressor(max_depth=2, random_state=0).fit(X, y)
|
|
61
|
+
assert "sklearnex" in rf.__module__
|
|
62
|
+
pred = _as_numpy(rf.predict([[0, 0, 0, 0]]))
|
|
63
|
+
if daal_check_version((2024, "P", 0)):
|
|
64
|
+
assert_allclose([-6.971], pred, atol=1e-2)
|
|
65
|
+
else:
|
|
66
|
+
assert_allclose([-6.839], pred, atol=1e-2)
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
# TODO:
|
|
70
|
+
# investigate failure for `dpnp.ndarrays` and `dpctl.tensors` on `GPU`
|
|
71
|
+
@pytest.mark.parametrize(
|
|
72
|
+
"dataframe,queue", get_dataframes_and_queues(device_filter_="cpu")
|
|
73
|
+
)
|
|
74
|
+
def test_sklearnex_import_et_classifier(dataframe, queue):
|
|
75
|
+
from sklearnex.ensemble import ExtraTreesClassifier
|
|
76
|
+
|
|
77
|
+
X, y = make_classification(
|
|
78
|
+
n_samples=1000,
|
|
79
|
+
n_features=4,
|
|
80
|
+
n_informative=2,
|
|
81
|
+
n_redundant=0,
|
|
82
|
+
random_state=0,
|
|
83
|
+
shuffle=False,
|
|
84
|
+
)
|
|
85
|
+
X = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
|
|
86
|
+
y = _convert_to_dataframe(y, sycl_queue=queue, target_df=dataframe)
|
|
87
|
+
# For the 2023.2 release, random_state is not supported
|
|
88
|
+
# defaults to seed=777, although it is set to 0
|
|
89
|
+
rf = ExtraTreesClassifier(max_depth=2, random_state=0).fit(X, y)
|
|
90
|
+
assert "sklearnex" in rf.__module__
|
|
91
|
+
assert_allclose([1], _as_numpy(rf.predict([[0, 0, 0, 0]])))
|
|
92
|
+
|
|
93
|
+
|
|
94
|
+
# TODO:
|
|
95
|
+
# investigate failure for `dpnp.ndarrays` and `dpctl.tensors` on `GPU`
|
|
96
|
+
@pytest.mark.parametrize(
|
|
97
|
+
"dataframe,queue", get_dataframes_and_queues(device_filter_="cpu")
|
|
98
|
+
)
|
|
99
|
+
def test_sklearnex_import_et_regression(dataframe, queue):
|
|
100
|
+
from sklearnex.ensemble import ExtraTreesRegressor
|
|
101
|
+
|
|
102
|
+
X, y = make_regression(n_features=1, random_state=0, shuffle=False)
|
|
103
|
+
X = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
|
|
104
|
+
y = _convert_to_dataframe(y, sycl_queue=queue, target_df=dataframe)
|
|
105
|
+
# For the 2023.2 release, random_state is not supported
|
|
106
|
+
# defaults to seed=777, although it is set to 0
|
|
107
|
+
rf = ExtraTreesRegressor(random_state=0).fit(X, y)
|
|
108
|
+
assert "sklearnex" in rf.__module__
|
|
109
|
+
pred = _as_numpy(
|
|
110
|
+
rf.predict(
|
|
111
|
+
[
|
|
112
|
+
[
|
|
113
|
+
0,
|
|
114
|
+
]
|
|
115
|
+
]
|
|
116
|
+
)
|
|
117
|
+
)
|
|
118
|
+
assert_allclose([0.445], pred, atol=1e-2)
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
|
-
|
|
2
|
+
# ===============================================================================
|
|
3
3
|
# Copyright 2021 Intel Corporation
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -13,10 +13,9 @@
|
|
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
# See the License for the specific language governing permissions and
|
|
15
15
|
# limitations under the License.
|
|
16
|
-
|
|
16
|
+
# ===============================================================================
|
|
17
17
|
|
|
18
|
-
from sklearnex import patch_sklearn
|
|
19
|
-
from sklearnex import unpatch_sklearn
|
|
18
|
+
from sklearnex import patch_sklearn, unpatch_sklearn
|
|
20
19
|
|
|
21
20
|
|
|
22
21
|
def _main():
|
|
@@ -34,15 +33,29 @@ def _main():
|
|
|
34
33
|
description="""
|
|
35
34
|
Patch all your Scikit-learn applications using Intel(R) Extension for
|
|
36
35
|
scikit-learn.""",
|
|
37
|
-
formatter_class=argparse.ArgumentDefaultsHelpFormatter
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
parser.
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
36
|
+
formatter_class=argparse.ArgumentDefaultsHelpFormatter,
|
|
37
|
+
)
|
|
38
|
+
|
|
39
|
+
parser.register("action", "extend", ExtendAction)
|
|
40
|
+
parser.add_argument(
|
|
41
|
+
"action",
|
|
42
|
+
choices=["patch_sklearn", "unpatch_sklearn"],
|
|
43
|
+
help="Enable or Disable patching",
|
|
44
|
+
)
|
|
45
|
+
parser.add_argument(
|
|
46
|
+
"--no-verbose",
|
|
47
|
+
"-nv",
|
|
48
|
+
action="store_false",
|
|
49
|
+
help="Disable additional information about enabling patching",
|
|
50
|
+
)
|
|
51
|
+
parser.add_argument(
|
|
52
|
+
"--algorithm",
|
|
53
|
+
"-a",
|
|
54
|
+
action="extend",
|
|
55
|
+
type=str,
|
|
56
|
+
nargs="+",
|
|
57
|
+
help="The name of an algorithm to be patched globally",
|
|
58
|
+
)
|
|
46
59
|
args = parser.parse_args()
|
|
47
60
|
|
|
48
61
|
if args.action == "patch_sklearn":
|
|
@@ -50,9 +63,11 @@ def _main():
|
|
|
50
63
|
elif args.action == "unpatch_sklearn":
|
|
51
64
|
unpatch_sklearn(global_unpatch=True)
|
|
52
65
|
else:
|
|
53
|
-
raise RuntimeError(
|
|
54
|
-
|
|
55
|
-
|
|
66
|
+
raise RuntimeError(
|
|
67
|
+
"Invalid choice for the action attribute."
|
|
68
|
+
" Expected: patch_sklearn or unpatch_sklearn."
|
|
69
|
+
f" Got {args.action}"
|
|
70
|
+
)
|
|
56
71
|
|
|
57
72
|
|
|
58
73
|
_main()
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
|
-
|
|
2
|
+
# ===============================================================================
|
|
3
3
|
# Copyright 2021 Intel Corporation
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -13,7 +13,8 @@
|
|
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
# See the License for the specific language governing permissions and
|
|
15
15
|
# limitations under the License.
|
|
16
|
-
|
|
16
|
+
# ===============================================================================
|
|
17
|
+
|
|
17
18
|
|
|
18
19
|
def get_patch_str(name=None, verbose=True):
|
|
19
20
|
return f"""try:
|
|
@@ -36,46 +37,52 @@ except ImportError:
|
|
|
36
37
|
def patch_sklearn_global(name=None, verbose=True):
|
|
37
38
|
import os
|
|
38
39
|
import re
|
|
40
|
+
|
|
39
41
|
try:
|
|
40
42
|
import sklearn
|
|
41
43
|
except ImportError:
|
|
42
44
|
raise ImportError("Scikit-learn could not be imported. Nothing to patch\n")
|
|
43
45
|
|
|
44
46
|
init_file_path = sklearn.__file__
|
|
45
|
-
distributor_file_path = os.path.join(
|
|
46
|
-
|
|
47
|
+
distributor_file_path = os.path.join(
|
|
48
|
+
os.path.dirname(init_file_path), "_distributor_init.py"
|
|
49
|
+
)
|
|
47
50
|
|
|
48
|
-
with open(distributor_file_path,
|
|
51
|
+
with open(distributor_file_path, "r", encoding="utf-8") as distributor_file:
|
|
49
52
|
lines = distributor_file.read()
|
|
50
53
|
if re.search(get_patch_str_re(), lines):
|
|
51
|
-
lines = re.sub(get_patch_str_re(),
|
|
54
|
+
lines = re.sub(get_patch_str_re(), "", lines)
|
|
52
55
|
|
|
53
|
-
with open(distributor_file_path,
|
|
56
|
+
with open(distributor_file_path, "w", encoding="utf-8") as distributor_file:
|
|
54
57
|
distributor_file.write(lines + "\n" + get_patch_str(name, verbose) + "\n")
|
|
55
|
-
print(
|
|
56
|
-
|
|
58
|
+
print(
|
|
59
|
+
"Scikit-learn was successfully globally patched"
|
|
60
|
+
" by Intel(R) Extension for Scikit-learn"
|
|
61
|
+
)
|
|
57
62
|
return
|
|
58
63
|
|
|
59
64
|
|
|
60
65
|
def unpatch_sklearn_global():
|
|
61
66
|
import os
|
|
62
67
|
import re
|
|
68
|
+
|
|
63
69
|
try:
|
|
64
70
|
import sklearn
|
|
65
71
|
except ImportError:
|
|
66
72
|
raise ImportError("Scikit-learn could not be imported. Nothing to unpatch\n")
|
|
67
73
|
|
|
68
74
|
init_file_path = sklearn.__file__
|
|
69
|
-
distributor_file_path = os.path.join(
|
|
70
|
-
|
|
75
|
+
distributor_file_path = os.path.join(
|
|
76
|
+
os.path.dirname(init_file_path), "_distributor_init.py"
|
|
77
|
+
)
|
|
71
78
|
|
|
72
|
-
with open(distributor_file_path,
|
|
79
|
+
with open(distributor_file_path, "r", encoding="utf-8") as distributor_file:
|
|
73
80
|
lines = distributor_file.read()
|
|
74
81
|
if not re.search(get_patch_str_re(), lines):
|
|
75
82
|
print("Nothing to unpatch: Scikit-learn is not patched\n")
|
|
76
83
|
return
|
|
77
|
-
lines = re.sub(get_patch_str_re(),
|
|
84
|
+
lines = re.sub(get_patch_str_re(), "", lines)
|
|
78
85
|
|
|
79
|
-
with open(distributor_file_path,
|
|
86
|
+
with open(distributor_file_path, "w", encoding="utf-8") as distributor_file:
|
|
80
87
|
distributor_file.write(lines)
|
|
81
88
|
print("Scikit-learn was successfully globally unpatched")
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
|
-
|
|
2
|
+
# ===============================================================================
|
|
3
3
|
# Copyright 2021 Intel Corporation
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -13,18 +13,18 @@
|
|
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
# See the License for the specific language governing permissions and
|
|
15
15
|
# limitations under the License.
|
|
16
|
-
|
|
16
|
+
# ===============================================================================
|
|
17
17
|
|
|
18
|
+
from .coordinate_descent import ElasticNet, Lasso
|
|
18
19
|
from .linear import LinearRegression
|
|
19
|
-
from .logistic_path import
|
|
20
|
+
from .logistic_path import LogisticRegression, logistic_regression_path
|
|
20
21
|
from .ridge import Ridge
|
|
21
|
-
from .coordinate_descent import ElasticNet, Lasso
|
|
22
22
|
|
|
23
23
|
__all__ = [
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
"Ridge",
|
|
25
|
+
"LinearRegression",
|
|
26
|
+
"LogisticRegression",
|
|
27
|
+
"logistic_regression_path",
|
|
28
|
+
"ElasticNet",
|
|
29
|
+
"Lasso",
|
|
30
30
|
]
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env python
|
|
2
|
-
|
|
2
|
+
# ===============================================================================
|
|
3
3
|
# Copyright 2021 Intel Corporation
|
|
4
4
|
#
|
|
5
5
|
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
@@ -13,6 +13,6 @@
|
|
|
13
13
|
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
14
14
|
# See the License for the specific language governing permissions and
|
|
15
15
|
# limitations under the License.
|
|
16
|
-
|
|
16
|
+
# ===============================================================================
|
|
17
17
|
|
|
18
18
|
from daal4py.sklearn.linear_model import ElasticNet, Lasso
|