scikit-learn-intelex 2024.3.0__py39-none-win_amd64.whl → 2024.5.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.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/_device_offload.py +39 -5
- {scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/spmd → scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex}/basic_statistics/__init__.py +2 -1
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/basic_statistics/incremental_basic_statistics.py +288 -0
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/basic_statistics/tests/test_incremental_basic_statistics.py +384 -0
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/covariance/incremental_covariance.py +317 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/covariance/tests/test_incremental_covariance.py +54 -17
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/decomposition/pca.py +71 -19
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/decomposition/tests/test_pca.py +2 -2
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/dispatcher.py +33 -2
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/ensemble/_forest.py +73 -79
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/linear_model/__init__.py +5 -3
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/linear_model/incremental_linear.py +387 -0
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/linear_model/linear.py +316 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/linear_model/logistic_regression.py +50 -9
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_incremental_linear.py +200 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/linear_model/tests/test_linear.py +40 -5
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/neighbors/_lof.py +53 -36
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/neighbors/common.py +4 -1
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/neighbors/knn_classification.py +37 -122
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/neighbors/knn_regression.py +10 -117
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/neighbors/knn_unsupervised.py +6 -78
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/neighbors/tests/test_neighbors.py +2 -2
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/k_means.py +5 -73
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/covariance.py +6 -5
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/tests/test_covariance.py +18 -5
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/svm/_common.py +4 -7
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/svm/nusvc.py +66 -50
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/svm/nusvr.py +3 -49
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/svm/svc.py +66 -51
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/svm/svr.py +3 -49
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/tests/_utils.py +34 -16
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/tests/test_memory_usage.py +5 -1
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/tests/test_n_jobs_support.py +12 -2
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/tests/test_patching.py +87 -58
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability_tests.py +1 -1
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/utils/__init__.py +2 -1
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/utils/_namespace.py +97 -0
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/utils/tests/test_finite.py +89 -0
- {scikit_learn_intelex-2024.3.0.dist-info → scikit_learn_intelex-2024.5.0.dist-info}/METADATA +227 -230
- scikit_learn_intelex-2024.5.0.dist-info/RECORD +104 -0
- {scikit_learn_intelex-2024.3.0.dist-info → scikit_learn_intelex-2024.5.0.dist-info}/WHEEL +1 -1
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/covariance/incremental_covariance.py +0 -130
- scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex/linear_model/linear.py +0 -381
- scikit_learn_intelex-2024.3.0.dist-info/RECORD +0 -98
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/__main__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/_config.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/_utils.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/basic_statistics/basic_statistics.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/cluster/dbscan.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/cluster/k_means.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/cluster/tests/test_dbscan.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/cluster/tests/test_kmeans.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/conftest.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/covariance/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/decomposition/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/doc/third-party-programs.txt +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/ensemble/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/ensemble/tests/test_forest.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/glob/__main__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/glob/dispatcher.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/linear_model/coordinate_descent.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/linear_model/logistic_path.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/linear_model/ridge.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/linear_model/tests/test_logreg.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/manifold/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/manifold/t_sne.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/manifold/tests/test_tsne.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/metrics/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/metrics/pairwise.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/metrics/ranking.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/metrics/tests/test_metrics.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/model_selection/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/model_selection/split.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/model_selection/tests/test_model_selection.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/neighbors/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/preview/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/_common.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data/data/Lib/site-packages/sklearnex → scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/spmd}/basic_statistics/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/basic_statistics/basic_statistics.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/dbscan.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/kmeans.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/covariance/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/covariance/covariance.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/decomposition/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/decomposition/pca.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/ensemble/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/ensemble/forest.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/linear_model.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/logistic_regression.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/neighbors/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/spmd/neighbors/neighbors.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/svm/__init__.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/svm/tests/test_svm.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/tests/test_config.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/tests/test_monkeypatch.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/tests/test_parallel.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/utils/parallel.py +0 -0
- {scikit_learn_intelex-2024.3.0.data → scikit_learn_intelex-2024.5.0.data}/data/Lib/site-packages/sklearnex/utils/validation.py +0 -0
- {scikit_learn_intelex-2024.3.0.dist-info → scikit_learn_intelex-2024.5.0.dist-info}/LICENSE.txt +0 -0
- {scikit_learn_intelex-2024.3.0.dist-info → scikit_learn_intelex-2024.5.0.dist-info}/top_level.txt +0 -0
|
@@ -17,11 +17,13 @@
|
|
|
17
17
|
import numpy as np
|
|
18
18
|
from scipy import sparse as sp
|
|
19
19
|
from sklearn.exceptions import NotFittedError
|
|
20
|
+
from sklearn.metrics import accuracy_score
|
|
20
21
|
from sklearn.svm import SVC as sklearn_SVC
|
|
21
22
|
from sklearn.utils.validation import _deprecate_positional_args
|
|
22
23
|
|
|
23
24
|
from daal4py.sklearn._n_jobs_support import control_n_jobs
|
|
24
25
|
from daal4py.sklearn._utils import sklearn_check_version
|
|
26
|
+
from sklearnex.utils import get_namespace
|
|
25
27
|
|
|
26
28
|
from .._device_offload import dispatch, wrap_output_data
|
|
27
29
|
from .._utils import PatchingConditionsChain
|
|
@@ -34,7 +36,7 @@ from onedal.svm import SVC as onedal_SVC
|
|
|
34
36
|
|
|
35
37
|
|
|
36
38
|
@control_n_jobs(
|
|
37
|
-
decorated_methods=["fit", "predict", "_predict_proba", "decision_function"]
|
|
39
|
+
decorated_methods=["fit", "predict", "_predict_proba", "decision_function", "score"]
|
|
38
40
|
)
|
|
39
41
|
class SVC(sklearn_SVC, BaseSVC):
|
|
40
42
|
__doc__ = sklearn_SVC.__doc__
|
|
@@ -81,39 +83,6 @@ class SVC(sklearn_SVC, BaseSVC):
|
|
|
81
83
|
)
|
|
82
84
|
|
|
83
85
|
def fit(self, X, y, sample_weight=None):
|
|
84
|
-
"""
|
|
85
|
-
Fit the SVM model according to the given training data.
|
|
86
|
-
|
|
87
|
-
Parameters
|
|
88
|
-
----------
|
|
89
|
-
X : {array-like, sparse matrix} of shape (n_samples, n_features) \
|
|
90
|
-
or (n_samples, n_samples)
|
|
91
|
-
Training vectors, where `n_samples` is the number of samples
|
|
92
|
-
and `n_features` is the number of features.
|
|
93
|
-
For kernel="precomputed", the expected shape of X is
|
|
94
|
-
(n_samples, n_samples).
|
|
95
|
-
|
|
96
|
-
y : array-like of shape (n_samples,)
|
|
97
|
-
Target values (class labels in classification, real numbers in
|
|
98
|
-
regression).
|
|
99
|
-
|
|
100
|
-
sample_weight : array-like of shape (n_samples,), default=None
|
|
101
|
-
Per-sample weights. Rescale C per sample. Higher weights
|
|
102
|
-
force the classifier to put more emphasis on these points.
|
|
103
|
-
|
|
104
|
-
Returns
|
|
105
|
-
-------
|
|
106
|
-
self : object
|
|
107
|
-
Fitted estimator.
|
|
108
|
-
|
|
109
|
-
Notes
|
|
110
|
-
-----
|
|
111
|
-
If X and y are not C-ordered and contiguous arrays of np.float64 and
|
|
112
|
-
X is not a scipy.sparse.csr_matrix, X and/or y may be copied.
|
|
113
|
-
|
|
114
|
-
If X is a dense array, then the other methods will not support sparse
|
|
115
|
-
matrices as input.
|
|
116
|
-
"""
|
|
117
86
|
if sklearn_check_version("1.2"):
|
|
118
87
|
self._validate_params()
|
|
119
88
|
if sklearn_check_version("1.0"):
|
|
@@ -133,22 +102,6 @@ class SVC(sklearn_SVC, BaseSVC):
|
|
|
133
102
|
|
|
134
103
|
@wrap_output_data
|
|
135
104
|
def predict(self, X):
|
|
136
|
-
"""
|
|
137
|
-
Perform regression on samples in X.
|
|
138
|
-
|
|
139
|
-
For an one-class model, +1 (inlier) or -1 (outlier) is returned.
|
|
140
|
-
|
|
141
|
-
Parameters
|
|
142
|
-
----------
|
|
143
|
-
X : {array-like, sparse matrix} of shape (n_samples, n_features)
|
|
144
|
-
For kernel="precomputed", the expected shape of X is
|
|
145
|
-
(n_samples_test, n_samples_train).
|
|
146
|
-
|
|
147
|
-
Returns
|
|
148
|
-
-------
|
|
149
|
-
y_pred : ndarray of shape (n_samples,)
|
|
150
|
-
The predicted values.
|
|
151
|
-
"""
|
|
152
105
|
if sklearn_check_version("1.0"):
|
|
153
106
|
self._check_feature_names(X, reset=False)
|
|
154
107
|
return dispatch(
|
|
@@ -161,6 +114,22 @@ class SVC(sklearn_SVC, BaseSVC):
|
|
|
161
114
|
X,
|
|
162
115
|
)
|
|
163
116
|
|
|
117
|
+
@wrap_output_data
|
|
118
|
+
def score(self, X, y, sample_weight=None):
|
|
119
|
+
if sklearn_check_version("1.0"):
|
|
120
|
+
self._check_feature_names(X, reset=False)
|
|
121
|
+
return dispatch(
|
|
122
|
+
self,
|
|
123
|
+
"score",
|
|
124
|
+
{
|
|
125
|
+
"onedal": self.__class__._onedal_score,
|
|
126
|
+
"sklearn": sklearn_SVC.score,
|
|
127
|
+
},
|
|
128
|
+
X,
|
|
129
|
+
y,
|
|
130
|
+
sample_weight=sample_weight,
|
|
131
|
+
)
|
|
132
|
+
|
|
164
133
|
if sklearn_check_version("1.0"):
|
|
165
134
|
|
|
166
135
|
@available_if(sklearn_SVC._check_proba)
|
|
@@ -193,6 +162,38 @@ class SVC(sklearn_SVC, BaseSVC):
|
|
|
193
162
|
"""
|
|
194
163
|
return self._predict_proba(X)
|
|
195
164
|
|
|
165
|
+
@available_if(sklearn_SVC._check_proba)
|
|
166
|
+
def predict_log_proba(self, X):
|
|
167
|
+
"""Compute log probabilities of possible outcomes for samples in X.
|
|
168
|
+
|
|
169
|
+
The model need to have probability information computed at training
|
|
170
|
+
time: fit with attribute `probability` set to True.
|
|
171
|
+
|
|
172
|
+
Parameters
|
|
173
|
+
----------
|
|
174
|
+
X : array-like of shape (n_samples, n_features) or \
|
|
175
|
+
(n_samples_test, n_samples_train)
|
|
176
|
+
For kernel="precomputed", the expected shape of X is
|
|
177
|
+
(n_samples_test, n_samples_train).
|
|
178
|
+
|
|
179
|
+
Returns
|
|
180
|
+
-------
|
|
181
|
+
T : ndarray of shape (n_samples, n_classes)
|
|
182
|
+
Returns the log-probabilities of the sample for each class in
|
|
183
|
+
the model. The columns correspond to the classes in sorted
|
|
184
|
+
order, as they appear in the attribute :term:`classes_`.
|
|
185
|
+
|
|
186
|
+
Notes
|
|
187
|
+
-----
|
|
188
|
+
The probability model is created using cross validation, so
|
|
189
|
+
the results can be slightly different than those obtained by
|
|
190
|
+
predict. Also, it will produce meaningless results on very small
|
|
191
|
+
datasets.
|
|
192
|
+
"""
|
|
193
|
+
xp, _ = get_namespace(X)
|
|
194
|
+
|
|
195
|
+
return xp.log(self.predict_proba(X))
|
|
196
|
+
|
|
196
197
|
else:
|
|
197
198
|
|
|
198
199
|
@property
|
|
@@ -200,6 +201,10 @@ class SVC(sklearn_SVC, BaseSVC):
|
|
|
200
201
|
self._check_proba()
|
|
201
202
|
return self._predict_proba
|
|
202
203
|
|
|
204
|
+
def _predict_log_proba(self, X):
|
|
205
|
+
xp, _ = get_namespace(X)
|
|
206
|
+
return xp.log(self.predict_proba(X))
|
|
207
|
+
|
|
203
208
|
predict_proba.__doc__ = sklearn_SVC.predict_proba.__doc__
|
|
204
209
|
|
|
205
210
|
@wrap_output_data
|
|
@@ -257,7 +262,7 @@ class SVC(sklearn_SVC, BaseSVC):
|
|
|
257
262
|
if method_name == "fit":
|
|
258
263
|
patching_status.and_conditions(conditions)
|
|
259
264
|
return patching_status
|
|
260
|
-
if method_name in ["predict", "predict_proba", "decision_function"]:
|
|
265
|
+
if method_name in ["predict", "predict_proba", "decision_function", "score"]:
|
|
261
266
|
conditions.append(
|
|
262
267
|
(hasattr(self, "_onedal_estimator"), "oneDAL model was not trained")
|
|
263
268
|
)
|
|
@@ -307,3 +312,13 @@ class SVC(sklearn_SVC, BaseSVC):
|
|
|
307
312
|
|
|
308
313
|
def _onedal_decision_function(self, X, queue=None):
|
|
309
314
|
return self._onedal_estimator.decision_function(X, queue=queue)
|
|
315
|
+
|
|
316
|
+
def _onedal_score(self, X, y, sample_weight=None, queue=None):
|
|
317
|
+
return accuracy_score(
|
|
318
|
+
y, self._onedal_predict(X, queue=queue), sample_weight=sample_weight
|
|
319
|
+
)
|
|
320
|
+
|
|
321
|
+
fit.__doc__ = sklearn_SVC.fit.__doc__
|
|
322
|
+
predict.__doc__ = sklearn_SVC.predict.__doc__
|
|
323
|
+
decision_function.__doc__ = sklearn_SVC.decision_function.__doc__
|
|
324
|
+
score.__doc__ = sklearn_SVC.score.__doc__
|
|
@@ -63,39 +63,6 @@ class SVR(sklearn_SVR, BaseSVR):
|
|
|
63
63
|
)
|
|
64
64
|
|
|
65
65
|
def fit(self, X, y, sample_weight=None):
|
|
66
|
-
"""
|
|
67
|
-
Fit the SVM model according to the given training data.
|
|
68
|
-
|
|
69
|
-
Parameters
|
|
70
|
-
----------
|
|
71
|
-
X : {array-like, sparse matrix} of shape (n_samples, n_features) \
|
|
72
|
-
or (n_samples, n_samples)
|
|
73
|
-
Training vectors, where `n_samples` is the number of samples
|
|
74
|
-
and `n_features` is the number of features.
|
|
75
|
-
For kernel="precomputed", the expected shape of X is
|
|
76
|
-
(n_samples, n_samples).
|
|
77
|
-
|
|
78
|
-
y : array-like of shape (n_samples,)
|
|
79
|
-
Target values (class labels in classification, real numbers in
|
|
80
|
-
regression).
|
|
81
|
-
|
|
82
|
-
sample_weight : array-like of shape (n_samples,), default=None
|
|
83
|
-
Per-sample weights. Rescale C per sample. Higher weights
|
|
84
|
-
force the classifier to put more emphasis on these points.
|
|
85
|
-
|
|
86
|
-
Returns
|
|
87
|
-
-------
|
|
88
|
-
self : object
|
|
89
|
-
Fitted estimator.
|
|
90
|
-
|
|
91
|
-
Notes
|
|
92
|
-
-----
|
|
93
|
-
If X and y are not C-ordered and contiguous arrays of np.float64 and
|
|
94
|
-
X is not a scipy.sparse.csr_matrix, X and/or y may be copied.
|
|
95
|
-
|
|
96
|
-
If X is a dense array, then the other methods will not support sparse
|
|
97
|
-
matrices as input.
|
|
98
|
-
"""
|
|
99
66
|
if sklearn_check_version("1.2"):
|
|
100
67
|
self._validate_params()
|
|
101
68
|
if sklearn_check_version("1.0"):
|
|
@@ -116,22 +83,6 @@ class SVR(sklearn_SVR, BaseSVR):
|
|
|
116
83
|
|
|
117
84
|
@wrap_output_data
|
|
118
85
|
def predict(self, X):
|
|
119
|
-
"""
|
|
120
|
-
Perform regression on samples in X.
|
|
121
|
-
|
|
122
|
-
For an one-class model, +1 (inlier) or -1 (outlier) is returned.
|
|
123
|
-
|
|
124
|
-
Parameters
|
|
125
|
-
----------
|
|
126
|
-
X : {array-like, sparse matrix} of shape (n_samples, n_features)
|
|
127
|
-
For kernel="precomputed", the expected shape of X is
|
|
128
|
-
(n_samples_test, n_samples_train).
|
|
129
|
-
|
|
130
|
-
Returns
|
|
131
|
-
-------
|
|
132
|
-
y_pred : ndarray of shape (n_samples,)
|
|
133
|
-
The predicted values.
|
|
134
|
-
"""
|
|
135
86
|
if sklearn_check_version("1.0"):
|
|
136
87
|
self._check_feature_names(X, reset=False)
|
|
137
88
|
return dispatch(
|
|
@@ -164,3 +115,6 @@ class SVR(sklearn_SVR, BaseSVR):
|
|
|
164
115
|
|
|
165
116
|
def _onedal_predict(self, X, queue=None):
|
|
166
117
|
return self._onedal_estimator.predict(X, queue=queue)
|
|
118
|
+
|
|
119
|
+
fit.__doc__ = sklearn_SVR.fit.__doc__
|
|
120
|
+
predict.__doc__ = sklearn_SVR.predict.__doc__
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
from inspect import isclass
|
|
18
18
|
|
|
19
19
|
import numpy as np
|
|
20
|
+
from sklearn import clone
|
|
20
21
|
from sklearn.base import (
|
|
21
22
|
BaseEstimator,
|
|
22
23
|
ClassifierMixin,
|
|
@@ -30,6 +31,7 @@ from sklearn.neighbors._base import KNeighborsMixin
|
|
|
30
31
|
|
|
31
32
|
from onedal.tests.utils._dataframes_support import _convert_to_dataframe
|
|
32
33
|
from sklearnex import get_patch_map, patch_sklearn, sklearn_is_patched, unpatch_sklearn
|
|
34
|
+
from sklearnex.linear_model import LogisticRegression
|
|
33
35
|
from sklearnex.neighbors import (
|
|
34
36
|
KNeighborsClassifier,
|
|
35
37
|
KNeighborsRegressor,
|
|
@@ -86,26 +88,38 @@ mixin_map = [
|
|
|
86
88
|
]
|
|
87
89
|
|
|
88
90
|
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
91
|
+
class _sklearn_clone_dict(dict):
|
|
92
|
+
|
|
93
|
+
def __getitem__(self, key):
|
|
94
|
+
return clone(super().__getitem__(key))
|
|
95
|
+
|
|
96
|
+
|
|
97
|
+
SPECIAL_INSTANCES = _sklearn_clone_dict(
|
|
98
|
+
{
|
|
99
|
+
str(i): i
|
|
100
|
+
for i in [
|
|
101
|
+
LocalOutlierFactor(novelty=True),
|
|
102
|
+
SVC(probability=True),
|
|
103
|
+
NuSVC(probability=True),
|
|
104
|
+
KNeighborsClassifier(algorithm="brute"),
|
|
105
|
+
KNeighborsRegressor(algorithm="brute"),
|
|
106
|
+
NearestNeighbors(algorithm="brute"),
|
|
107
|
+
LogisticRegression(solver="newton-cg"),
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
)
|
|
100
111
|
|
|
101
112
|
|
|
102
113
|
def gen_models_info(algorithms):
|
|
103
114
|
output = []
|
|
104
115
|
for i in algorithms:
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
116
|
+
|
|
117
|
+
if i in PATCHED_MODELS:
|
|
118
|
+
est = PATCHED_MODELS[i]
|
|
119
|
+
elif i in SPECIAL_INSTANCES:
|
|
120
|
+
est = SPECIAL_INSTANCES[i].__class__
|
|
121
|
+
else:
|
|
122
|
+
raise KeyError(f"Unrecognized sklearnex estimator: {i}")
|
|
109
123
|
|
|
110
124
|
methods = set()
|
|
111
125
|
candidates = set(
|
|
@@ -116,7 +130,11 @@ def gen_models_info(algorithms):
|
|
|
116
130
|
if issubclass(est, mixin):
|
|
117
131
|
methods |= candidates & set(method)
|
|
118
132
|
|
|
119
|
-
output += [[i, j] for j in methods]
|
|
133
|
+
output += [[i, j] for j in methods] if methods else [[i, None]]
|
|
134
|
+
|
|
135
|
+
# In the case that no methods are available, set method to None.
|
|
136
|
+
# This will allow estimators without mixins to still test the fit
|
|
137
|
+
# method in various tests.
|
|
120
138
|
return output
|
|
121
139
|
|
|
122
140
|
|
|
@@ -96,7 +96,11 @@ def remove_duplicated_estimators(estimators_list):
|
|
|
96
96
|
return estimators_map.values()
|
|
97
97
|
|
|
98
98
|
|
|
99
|
-
BANNED_ESTIMATORS = (
|
|
99
|
+
BANNED_ESTIMATORS = (
|
|
100
|
+
"IncrementalEmpiricalCovariance", # dataframe_f issues
|
|
101
|
+
"IncrementalLinearRegression", # TODO fix memory leak issue in private CI for data_shape = (1000, 100), data_transform_function = dataframe_f
|
|
102
|
+
"TSNE", # too slow for using in testing on common data size
|
|
103
|
+
)
|
|
100
104
|
estimators = [
|
|
101
105
|
TrainTestSplitEstimator,
|
|
102
106
|
FiniteCheckEstimator,
|
|
@@ -22,6 +22,7 @@ import pytest
|
|
|
22
22
|
from sklearn.base import BaseEstimator
|
|
23
23
|
from sklearn.datasets import make_classification
|
|
24
24
|
|
|
25
|
+
from sklearnex.decomposition import PCA
|
|
25
26
|
from sklearnex.dispatcher import get_patch_map
|
|
26
27
|
from sklearnex.svm import SVC, NuSVC
|
|
27
28
|
|
|
@@ -73,6 +74,9 @@ def test_n_jobs_support(caplog, estimator_class, n_jobs):
|
|
|
73
74
|
# by default, [Nu]SVC.predict_proba is restricted by @available_if decorator
|
|
74
75
|
if estimator_class in [SVC, NuSVC]:
|
|
75
76
|
estimator_kwargs["probability"] = True
|
|
77
|
+
# explicitly request oneDAL's PCA-Covariance algorithm
|
|
78
|
+
if estimator_class == PCA:
|
|
79
|
+
estimator_kwargs["svd_solver"] = "covariance_eigh"
|
|
76
80
|
estimator_instance = estimator_class(**estimator_kwargs)
|
|
77
81
|
# check `n_jobs` parameter doc entry
|
|
78
82
|
check_estimator_doc(estimator_class)
|
|
@@ -84,10 +88,16 @@ def test_n_jobs_support(caplog, estimator_class, n_jobs):
|
|
|
84
88
|
if method_name == "fit":
|
|
85
89
|
continue
|
|
86
90
|
method = getattr(estimator_instance, method_name)
|
|
87
|
-
|
|
91
|
+
argdict = inspect.signature(method).parameters
|
|
92
|
+
argnum = len(
|
|
93
|
+
[i for i in argdict if argdict[i].default == inspect.Parameter.empty]
|
|
94
|
+
)
|
|
95
|
+
if argnum == 0:
|
|
88
96
|
check_method(method=method, caplog=caplog)
|
|
89
|
-
|
|
97
|
+
elif argnum == 1:
|
|
90
98
|
check_method(X, method=method, caplog=caplog)
|
|
99
|
+
else:
|
|
100
|
+
check_method(X, Y, method=method, caplog=caplog)
|
|
91
101
|
# check if correct methods were decorated
|
|
92
102
|
check_methods_decoration(estimator_class)
|
|
93
103
|
check_methods_decoration(estimator_instance)
|
|
@@ -26,24 +26,7 @@ from inspect import signature
|
|
|
26
26
|
import numpy as np
|
|
27
27
|
import numpy.random as nprnd
|
|
28
28
|
import pytest
|
|
29
|
-
from
|
|
30
|
-
DTYPES,
|
|
31
|
-
PATCHED_FUNCTIONS,
|
|
32
|
-
PATCHED_MODELS,
|
|
33
|
-
SPECIAL_INSTANCES,
|
|
34
|
-
UNPATCHED_FUNCTIONS,
|
|
35
|
-
UNPATCHED_MODELS,
|
|
36
|
-
gen_dataset,
|
|
37
|
-
gen_models_info,
|
|
38
|
-
)
|
|
39
|
-
from sklearn.base import (
|
|
40
|
-
BaseEstimator,
|
|
41
|
-
ClassifierMixin,
|
|
42
|
-
ClusterMixin,
|
|
43
|
-
OutlierMixin,
|
|
44
|
-
RegressorMixin,
|
|
45
|
-
TransformerMixin,
|
|
46
|
-
)
|
|
29
|
+
from sklearn.base import BaseEstimator
|
|
47
30
|
|
|
48
31
|
from daal4py.sklearn._utils import sklearn_check_version
|
|
49
32
|
from onedal.tests.utils._dataframes_support import (
|
|
@@ -53,21 +36,42 @@ from onedal.tests.utils._dataframes_support import (
|
|
|
53
36
|
from sklearnex import is_patched_instance
|
|
54
37
|
from sklearnex.dispatcher import _is_preview_enabled
|
|
55
38
|
from sklearnex.metrics import pairwise_distances, roc_auc_score
|
|
39
|
+
from sklearnex.tests._utils import (
|
|
40
|
+
DTYPES,
|
|
41
|
+
PATCHED_FUNCTIONS,
|
|
42
|
+
PATCHED_MODELS,
|
|
43
|
+
SPECIAL_INSTANCES,
|
|
44
|
+
UNPATCHED_FUNCTIONS,
|
|
45
|
+
UNPATCHED_MODELS,
|
|
46
|
+
gen_dataset,
|
|
47
|
+
gen_models_info,
|
|
48
|
+
)
|
|
56
49
|
|
|
57
50
|
|
|
58
51
|
@pytest.mark.parametrize("dtype", DTYPES)
|
|
59
|
-
@pytest.mark.parametrize(
|
|
60
|
-
"dataframe, queue", get_dataframes_and_queues(dataframe_filter_="numpy")
|
|
61
|
-
)
|
|
52
|
+
@pytest.mark.parametrize("dataframe, queue", get_dataframes_and_queues())
|
|
62
53
|
@pytest.mark.parametrize("metric", ["cosine", "correlation"])
|
|
63
54
|
def test_pairwise_distances_patching(caplog, dataframe, queue, dtype, metric):
|
|
64
55
|
with caplog.at_level(logging.WARNING, logger="sklearnex"):
|
|
56
|
+
if dtype == np.float16 and queue and not queue.sycl_device.has_aspect_fp16:
|
|
57
|
+
pytest.skip("Hardware does not support fp16 SYCL testing")
|
|
58
|
+
elif dtype == np.float64 and queue and not queue.sycl_device.has_aspect_fp64:
|
|
59
|
+
pytest.skip("Hardware does not support fp64 SYCL testing")
|
|
60
|
+
elif queue and queue.sycl_device.is_gpu:
|
|
61
|
+
pytest.skip("pairwise_distances does not support GPU queues")
|
|
62
|
+
|
|
65
63
|
rng = nprnd.default_rng()
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
64
|
+
if dataframe == "pandas":
|
|
65
|
+
X = _convert_to_dataframe(
|
|
66
|
+
rng.random(size=1000).astype(dtype).reshape(1, -1),
|
|
67
|
+
target_df=dataframe,
|
|
68
|
+
)
|
|
69
|
+
else:
|
|
70
|
+
X = _convert_to_dataframe(
|
|
71
|
+
rng.random(size=1000), sycl_queue=queue, target_df=dataframe, dtype=dtype
|
|
72
|
+
)[None, :]
|
|
69
73
|
|
|
70
|
-
_ = pairwise_distances(X
|
|
74
|
+
_ = pairwise_distances(X, metric=metric)
|
|
71
75
|
assert all(
|
|
72
76
|
[
|
|
73
77
|
"running accelerated version" in i.message
|
|
@@ -80,22 +84,26 @@ def test_pairwise_distances_patching(caplog, dataframe, queue, dtype, metric):
|
|
|
80
84
|
@pytest.mark.parametrize(
|
|
81
85
|
"dtype", [i for i in DTYPES if "32" in i.__name__ or "64" in i.__name__]
|
|
82
86
|
)
|
|
83
|
-
@pytest.mark.parametrize(
|
|
84
|
-
"dataframe, queue", get_dataframes_and_queues(dataframe_filter_="numpy")
|
|
85
|
-
)
|
|
87
|
+
@pytest.mark.parametrize("dataframe, queue", get_dataframes_and_queues())
|
|
86
88
|
def test_roc_auc_score_patching(caplog, dataframe, queue, dtype):
|
|
87
89
|
if dtype in [np.uint32, np.uint64] and sys.platform == "win32":
|
|
88
90
|
pytest.skip("Windows issue with unsigned ints")
|
|
91
|
+
elif dtype == np.float64 and queue and not queue.sycl_device.has_aspect_fp64:
|
|
92
|
+
pytest.skip("Hardware does not support fp64 SYCL testing")
|
|
93
|
+
|
|
89
94
|
with caplog.at_level(logging.WARNING, logger="sklearnex"):
|
|
90
95
|
rng = nprnd.default_rng()
|
|
96
|
+
X = rng.integers(2, size=1000)
|
|
97
|
+
y = rng.integers(2, size=1000)
|
|
98
|
+
|
|
91
99
|
X = _convert_to_dataframe(
|
|
92
|
-
|
|
100
|
+
X,
|
|
93
101
|
sycl_queue=queue,
|
|
94
102
|
target_df=dataframe,
|
|
95
103
|
dtype=dtype,
|
|
96
104
|
)
|
|
97
105
|
y = _convert_to_dataframe(
|
|
98
|
-
|
|
106
|
+
y,
|
|
99
107
|
sycl_queue=queue,
|
|
100
108
|
target_df=dataframe,
|
|
101
109
|
dtype=dtype,
|
|
@@ -112,14 +120,25 @@ def test_roc_auc_score_patching(caplog, dataframe, queue, dtype):
|
|
|
112
120
|
|
|
113
121
|
|
|
114
122
|
@pytest.mark.parametrize("dtype", DTYPES)
|
|
115
|
-
@pytest.mark.parametrize(
|
|
116
|
-
"dataframe, queue", get_dataframes_and_queues(dataframe_filter_="numpy")
|
|
117
|
-
)
|
|
123
|
+
@pytest.mark.parametrize("dataframe, queue", get_dataframes_and_queues())
|
|
118
124
|
@pytest.mark.parametrize("estimator, method", gen_models_info(PATCHED_MODELS))
|
|
119
125
|
def test_standard_estimator_patching(caplog, dataframe, queue, dtype, estimator, method):
|
|
120
126
|
with caplog.at_level(logging.WARNING, logger="sklearnex"):
|
|
121
127
|
est = PATCHED_MODELS[estimator]()
|
|
122
128
|
|
|
129
|
+
if queue:
|
|
130
|
+
if dtype == np.float16 and not queue.sycl_device.has_aspect_fp16:
|
|
131
|
+
pytest.skip("Hardware does not support fp16 SYCL testing")
|
|
132
|
+
elif dtype == np.float64 and not queue.sycl_device.has_aspect_fp64:
|
|
133
|
+
pytest.skip("Hardware does not support fp64 SYCL testing")
|
|
134
|
+
elif queue.sycl_device.is_gpu and estimator in [
|
|
135
|
+
"KMeans",
|
|
136
|
+
"ElasticNet",
|
|
137
|
+
"Lasso",
|
|
138
|
+
"Ridge",
|
|
139
|
+
]:
|
|
140
|
+
pytest.skip(f"{estimator} does not support GPU queues")
|
|
141
|
+
|
|
123
142
|
if estimator == "TSNE" and method == "fit_transform":
|
|
124
143
|
pytest.skip("TSNE.fit_transform is too slow for common testing")
|
|
125
144
|
elif (
|
|
@@ -129,15 +148,30 @@ def test_standard_estimator_patching(caplog, dataframe, queue, dtype, estimator,
|
|
|
129
148
|
and dtype in [np.uint32, np.uint64]
|
|
130
149
|
):
|
|
131
150
|
pytest.skip("Windows segmentation fault for Ridge.predict for unsigned ints")
|
|
132
|
-
elif
|
|
151
|
+
elif estimator == "IncrementalLinearRegression" and dtype in [
|
|
152
|
+
np.int8,
|
|
153
|
+
np.int16,
|
|
154
|
+
np.int32,
|
|
155
|
+
np.int64,
|
|
156
|
+
np.uint8,
|
|
157
|
+
np.uint16,
|
|
158
|
+
np.uint32,
|
|
159
|
+
np.uint64,
|
|
160
|
+
]:
|
|
161
|
+
pytest.skip(
|
|
162
|
+
"IncrementalLinearRegression fails on oneDAL side with int types because dataset is filled by zeroes"
|
|
163
|
+
)
|
|
164
|
+
elif method and not hasattr(est, method):
|
|
133
165
|
pytest.skip(f"sklearn available_if prevents testing {estimator}.{method}")
|
|
166
|
+
|
|
134
167
|
X, y = gen_dataset(est, queue=queue, target_df=dataframe, dtype=dtype)
|
|
135
168
|
est.fit(X, y)
|
|
136
169
|
|
|
137
|
-
if method
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
170
|
+
if method:
|
|
171
|
+
if method != "score":
|
|
172
|
+
getattr(est, method)(X)
|
|
173
|
+
else:
|
|
174
|
+
est.score(X, y)
|
|
141
175
|
assert all(
|
|
142
176
|
[
|
|
143
177
|
"running accelerated version" in i.message
|
|
@@ -148,9 +182,7 @@ def test_standard_estimator_patching(caplog, dataframe, queue, dtype, estimator,
|
|
|
148
182
|
|
|
149
183
|
|
|
150
184
|
@pytest.mark.parametrize("dtype", DTYPES)
|
|
151
|
-
@pytest.mark.parametrize(
|
|
152
|
-
"dataframe, queue", get_dataframes_and_queues(dataframe_filter_="numpy")
|
|
153
|
-
)
|
|
185
|
+
@pytest.mark.parametrize("dataframe, queue", get_dataframes_and_queues())
|
|
154
186
|
@pytest.mark.parametrize("estimator, method", gen_models_info(SPECIAL_INSTANCES))
|
|
155
187
|
def test_special_estimator_patching(caplog, dataframe, queue, dtype, estimator, method):
|
|
156
188
|
# prepare logging
|
|
@@ -158,15 +190,24 @@ def test_special_estimator_patching(caplog, dataframe, queue, dtype, estimator,
|
|
|
158
190
|
with caplog.at_level(logging.WARNING, logger="sklearnex"):
|
|
159
191
|
est = SPECIAL_INSTANCES[estimator]
|
|
160
192
|
|
|
193
|
+
# Its not possible to get the dpnp/dpctl arrays to be in the proper dtype
|
|
194
|
+
if dtype == np.float16 and queue and not queue.sycl_device.has_aspect_fp16:
|
|
195
|
+
pytest.skip("Hardware does not support fp16 SYCL testing")
|
|
196
|
+
elif dtype == np.float64 and queue and not queue.sycl_device.has_aspect_fp64:
|
|
197
|
+
pytest.skip("Hardware does not support fp64 SYCL testing")
|
|
198
|
+
|
|
161
199
|
X, y = gen_dataset(est, queue=queue, target_df=dataframe, dtype=dtype)
|
|
162
200
|
est.fit(X, y)
|
|
163
201
|
|
|
164
|
-
if not hasattr(est, method):
|
|
202
|
+
if method and not hasattr(est, method):
|
|
165
203
|
pytest.skip(f"sklearn available_if prevents testing {estimator}.{method}")
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
204
|
+
|
|
205
|
+
if method:
|
|
206
|
+
if method != "score":
|
|
207
|
+
getattr(est, method)(X)
|
|
208
|
+
else:
|
|
209
|
+
est.score(X, y)
|
|
210
|
+
|
|
170
211
|
assert all(
|
|
171
212
|
[
|
|
172
213
|
"running accelerated version" in i.message
|
|
@@ -311,18 +352,6 @@ def test_if_estimator_inherits_sklearn(estimator):
|
|
|
311
352
|
), f"{estimator} does not inherit from the patched sklearn estimator"
|
|
312
353
|
else:
|
|
313
354
|
assert issubclass(est, BaseEstimator)
|
|
314
|
-
assert any(
|
|
315
|
-
[
|
|
316
|
-
issubclass(est, i)
|
|
317
|
-
for i in [
|
|
318
|
-
ClassifierMixin,
|
|
319
|
-
ClusterMixin,
|
|
320
|
-
OutlierMixin,
|
|
321
|
-
RegressorMixin,
|
|
322
|
-
TransformerMixin,
|
|
323
|
-
]
|
|
324
|
-
]
|
|
325
|
-
), f"{estimator} does not inherit a sklearn Mixin"
|
|
326
355
|
|
|
327
356
|
|
|
328
357
|
@pytest.mark.parametrize("estimator", UNPATCHED_MODELS.keys())
|
|
@@ -294,7 +294,7 @@ MODELS_INFO = [
|
|
|
294
294
|
"dataset": "regression",
|
|
295
295
|
},
|
|
296
296
|
{
|
|
297
|
-
"model": PCA(n_components=0.5, svd_solver="
|
|
297
|
+
"model": PCA(n_components=0.5, svd_solver="covariance_eigh", random_state=0),
|
|
298
298
|
"methods": ["transform", "get_covariance", "get_precision", "score_samples"],
|
|
299
299
|
"dataset": "classifier",
|
|
300
300
|
},
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
# ===============================================================================
|
|
16
16
|
|
|
17
|
+
from ._namespace import get_namespace
|
|
17
18
|
from .validation import _assert_all_finite
|
|
18
19
|
|
|
19
|
-
__all__ = ["_assert_all_finite"]
|
|
20
|
+
__all__ = ["get_namespace", "_assert_all_finite"]
|