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.

Files changed (109) hide show
  1. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/__init__.py +2 -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
  3. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/_config.py +2 -2
  4. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/_device_offload.py +90 -56
  5. scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/_utils.py +95 -0
  6. {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
  7. {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
  8. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/cluster/__init__.py +4 -4
  9. scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/cluster/dbscan.py +187 -0
  10. {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
  11. {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
  12. {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
  13. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/decomposition/__init__.py +3 -3
  14. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/decomposition/pca.py +2 -2
  15. {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
  16. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/dispatcher.py +102 -72
  17. {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
  18. scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/ensemble/_forest.py +1947 -0
  19. scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/ensemble/tests/test_forest.py +118 -0
  20. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/glob/__main__.py +31 -16
  21. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/glob/dispatcher.py +21 -14
  22. {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
  23. {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
  24. {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
  25. {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
  26. {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
  27. {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
  28. {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
  29. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/manifold/__init__.py +3 -3
  30. {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
  31. {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
  32. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/metrics/__init__.py +5 -5
  33. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/metrics/pairwise.py +2 -2
  34. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/metrics/ranking.py +2 -2
  35. {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
  36. {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
  37. {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
  38. {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
  39. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/neighbors/__init__.py +9 -5
  40. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/neighbors/common.py +100 -77
  41. scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/neighbors/knn_classification.py +331 -0
  42. scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/neighbors/knn_regression.py +307 -0
  43. {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
  44. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/neighbors/lof.py +118 -56
  45. scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/neighbors/tests/test_neighbors.py +85 -0
  46. {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
  47. {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
  48. {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
  49. {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
  50. 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
  51. {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
  52. 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
  53. {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
  54. {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
  55. {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
  56. {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
  57. scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/spmd/cluster/dbscan.py +50 -0
  58. {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
  59. {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
  60. {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
  61. {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
  62. {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
  63. {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
  64. {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
  65. {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
  66. {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
  67. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/svm/__init__.py +11 -8
  68. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/svm/_common.py +56 -56
  69. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/svm/nusvc.py +110 -55
  70. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/svm/nusvr.py +65 -31
  71. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/svm/svc.py +136 -78
  72. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/svm/svr.py +65 -31
  73. scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/svm/tests/test_svm.py +102 -0
  74. scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/tests/_models_info.py +170 -0
  75. {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
  76. {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
  77. {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
  78. scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/tests/test_parallel.py +50 -0
  79. {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
  80. scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability_tests.py +428 -0
  81. {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
  82. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/utils/__init__.py +3 -3
  83. scikit_learn_intelex-2024.0.1.data/data/Lib/site-packages/sklearnex/utils/parallel.py +59 -0
  84. {scikit_learn_intelex-2023.2.1.data → scikit_learn_intelex-2024.0.1.data}/data/Lib/site-packages/sklearnex/utils/validation.py +2 -2
  85. {scikit_learn_intelex-2023.2.1.dist-info → scikit_learn_intelex-2024.0.1.dist-info}/METADATA +34 -35
  86. scikit_learn_intelex-2024.0.1.dist-info/RECORD +90 -0
  87. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/_utils.py +0 -82
  88. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/cluster/dbscan.py +0 -18
  89. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/ensemble/__init__.py +0 -20
  90. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/ensemble/forest.py +0 -18
  91. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/ensemble/tests/test_forest.py +0 -46
  92. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/neighbors/knn_classification.py +0 -228
  93. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/neighbors/knn_regression.py +0 -213
  94. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/neighbors/tests/test_neighbors.py +0 -57
  95. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/__init__.py +0 -18
  96. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/decomposition/tests/test_preview_pca.py +0 -28
  97. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/ensemble/extra_trees.py +0 -1261
  98. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/ensemble/forest.py +0 -1155
  99. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/ensemble/tests/test_preview_ensemble.py +0 -67
  100. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/preview/linear_model/_common.py +0 -66
  101. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/spmd/__init__.py +0 -23
  102. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/svm/tests/test_svm.py +0 -63
  103. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/tests/_models_info.py +0 -159
  104. scikit_learn_intelex-2023.2.1.data/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability_tests.py +0 -383
  105. scikit_learn_intelex-2023.2.1.dist-info/RECORD +0 -95
  106. {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
  107. {scikit_learn_intelex-2023.2.1.dist-info → scikit_learn_intelex-2024.0.1.dist-info}/LICENSE.txt +0 -0
  108. {scikit_learn_intelex-2023.2.1.dist-info → scikit_learn_intelex-2024.0.1.dist-info}/WHEEL +0 -0
  109. {scikit_learn_intelex-2023.2.1.dist-info → scikit_learn_intelex-2024.0.1.dist-info}/top_level.txt +0 -0
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env python
2
- #===============================================================================
2
+ # ===============================================================================
3
3
  # Copyright 2023 Intel Corporation
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -13,34 +13,37 @@
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
- import numpy as np
19
18
  import numbers
20
19
  from math import sqrt
20
+
21
+ import numpy as np
21
22
  from scipy.sparse import issparse
23
+ from sklearn.base import BaseEstimator
24
+ from sklearn.utils.extmath import stable_cumsum
25
+ from sklearn.utils.validation import check_array, check_is_fitted
22
26
 
23
- from ..._device_offload import dispatch
24
27
  from daal4py.sklearn._utils import sklearn_check_version
28
+ from onedal.utils import _check_array
25
29
 
26
- from sklearn.utils.extmath import stable_cumsum
27
- from onedal.datatypes import _check_array
28
- from sklearn.utils.validation import check_array
29
- from sklearn.base import BaseEstimator
30
- from sklearn.utils.validation import check_is_fitted
31
- if sklearn_check_version('1.1') and not sklearn_check_version('1.2'):
30
+ from ..._device_offload import dispatch
31
+ from ..._utils import PatchingConditionsChain
32
+
33
+ if sklearn_check_version("1.1") and not sklearn_check_version("1.2"):
32
34
  from sklearn.utils import check_scalar
33
- if sklearn_check_version('0.23'):
35
+ if sklearn_check_version("0.23"):
34
36
  from sklearn.decomposition._pca import _infer_dimension
35
37
  else:
36
38
  from sklearn.decomposition._pca import _infer_dimension_
37
39
 
38
- from onedal.decomposition import PCA as onedal_PCA
39
40
  from sklearn.decomposition import PCA as sklearn_PCA
40
41
 
42
+ from onedal.decomposition import PCA as onedal_PCA
43
+
41
44
 
42
45
  class PCA(sklearn_PCA):
43
- if sklearn_check_version('1.2'):
46
+ if sklearn_check_version("1.2"):
44
47
  _parameter_constraints: dict = {**sklearn_PCA._parameter_constraints}
45
48
 
46
49
  def __init__(
@@ -66,13 +69,11 @@ class PCA(sklearn_PCA):
66
69
  self.power_iteration_normalizer = power_iteration_normalizer
67
70
  self.random_state = random_state
68
71
 
69
- def _validate_n_components(self, n_components, n_samples,
70
- n_features, n_sf_min):
72
+ def _validate_n_components(self, n_components, n_samples, n_features, n_sf_min):
71
73
  if n_components == "mle":
72
74
  if n_samples < n_features:
73
75
  raise ValueError(
74
- "n_components='mle' is only supported if"
75
- " n_samples >= n_features"
76
+ "n_components='mle' is only supported if" " n_samples >= n_features"
76
77
  )
77
78
  elif not 0 <= n_components <= n_sf_min:
78
79
  raise ValueError(
@@ -82,15 +83,16 @@ class PCA(sklearn_PCA):
82
83
  )
83
84
  elif n_components >= 1:
84
85
  if not isinstance(n_components, numbers.Integral):
85
- raise ValueError("n_components=%r must be of type int "
86
- "when greater than or equal to 1, "
87
- "was of type=%r"
88
- % (n_components, type(n_components)))
86
+ raise ValueError(
87
+ "n_components=%r must be of type int "
88
+ "when greater than or equal to 1, "
89
+ "was of type=%r" % (n_components, type(n_components))
90
+ )
89
91
 
90
92
  def fit(self, X, y=None):
91
- if sklearn_check_version('1.2'):
93
+ if sklearn_check_version("1.2"):
92
94
  self._validate_params()
93
- elif sklearn_check_version('1.1'):
95
+ elif sklearn_check_version("1.1"):
94
96
  check_scalar(
95
97
  self.n_oversamples,
96
98
  "n_oversamples",
@@ -107,12 +109,14 @@ class PCA(sklearn_PCA):
107
109
  "TruncatedSVD for a possible alternative."
108
110
  )
109
111
 
110
- if sklearn_check_version('0.23'):
111
- X = self._validate_data(X, dtype=[np.float64, np.float32],
112
- ensure_2d=True, copy=False)
112
+ if sklearn_check_version("0.23"):
113
+ X = self._validate_data(
114
+ X, dtype=[np.float64, np.float32], ensure_2d=True, copy=False
115
+ )
113
116
  else:
114
- X = _check_array(X, dtype=[np.float64, np.float32],
115
- ensure_2d=True, copy=False)
117
+ X = _check_array(
118
+ X, dtype=[np.float64, np.float32], ensure_2d=True, copy=False
119
+ )
116
120
 
117
121
  n_samples, n_features = X.shape
118
122
  n_sf_min = min(n_samples, n_features)
@@ -125,13 +129,12 @@ class PCA(sklearn_PCA):
125
129
  else:
126
130
  n_components = self.n_components
127
131
 
128
- self._validate_n_components(n_components, n_samples, n_features,
129
- n_sf_min)
132
+ self._validate_n_components(n_components, n_samples, n_features, n_sf_min)
130
133
 
131
134
  self._fit_svd_solver = self.svd_solver
132
135
  shape_good_for_daal = X.shape[1] / X.shape[0] < 2
133
136
  if self._fit_svd_solver == "auto":
134
- if sklearn_check_version('1.1'):
137
+ if sklearn_check_version("1.1"):
135
138
  if max(X.shape) <= 500 or n_components == "mle":
136
139
  self._fit_svd_solver = "full"
137
140
  elif 1 <= n_components < 0.8 * n_sf_min:
@@ -139,69 +142,93 @@ class PCA(sklearn_PCA):
139
142
  else:
140
143
  self._fit_svd_solver = "full"
141
144
  else:
142
- if n_components == 'mle':
143
- self._fit_svd_solver = 'full'
145
+ if n_components == "mle":
146
+ self._fit_svd_solver = "full"
144
147
  else:
145
148
  n, p, k = X.shape[0], X.shape[1], n_components
146
149
  # check if sklearnex is faster than randomized sklearn
147
150
  # Refer to daal4py
148
- regression_coefs = np.array([
149
- [9.779873e-11, n * p * k],
150
- [-1.122062e-11, n * p * p],
151
- [1.127905e-09, n ** 2],
152
- ])
153
-
154
- if n_components >= 1 and np.dot(
155
- regression_coefs[:, 0],
156
- regression_coefs[:, 1]) <= 0:
157
- self._fit_svd_solver = 'randomized'
151
+ regression_coefs = np.array(
152
+ [
153
+ [9.779873e-11, n * p * k],
154
+ [-1.122062e-11, n * p * p],
155
+ [1.127905e-09, n**2],
156
+ ]
157
+ )
158
+
159
+ if (
160
+ n_components >= 1
161
+ and np.dot(regression_coefs[:, 0], regression_coefs[:, 1]) <= 0
162
+ ):
163
+ self._fit_svd_solver = "randomized"
158
164
  else:
159
- self._fit_svd_solver = 'full'
165
+ self._fit_svd_solver = "full"
160
166
 
161
- if not shape_good_for_daal or self._fit_svd_solver != 'full':
162
- if sklearn_check_version('0.23'):
167
+ if not shape_good_for_daal or self._fit_svd_solver != "full":
168
+ if sklearn_check_version("0.23"):
163
169
  X = self._validate_data(X, copy=self.copy)
164
170
  else:
165
171
  X = check_array(X, copy=self.copy)
166
172
 
167
173
  # Call different fits for either full or truncated SVD
168
174
  if shape_good_for_daal and self._fit_svd_solver == "full":
169
- return dispatch(self, 'fit', {
170
- 'onedal': self.__class__._onedal_fit,
171
- 'sklearn': sklearn_PCA._fit_full,
172
- }, X)
175
+ return dispatch(
176
+ self,
177
+ "fit",
178
+ {
179
+ "onedal": self.__class__._onedal_fit,
180
+ "sklearn": sklearn_PCA._fit_full,
181
+ },
182
+ X,
183
+ )
173
184
  elif not shape_good_for_daal and self._fit_svd_solver == "full":
174
185
  return sklearn_PCA._fit_full(self, X, n_components)
175
186
  elif self._fit_svd_solver in ["arpack", "randomized"]:
176
187
  return sklearn_PCA._fit_truncated(
177
- self, X, n_components, self._fit_svd_solver,
188
+ self,
189
+ X,
190
+ n_components,
191
+ self._fit_svd_solver,
178
192
  )
179
193
  else:
180
- raise ValueError(
181
- "Unrecognized svd_solver='{0}'".format(self._fit_svd_solver)
182
- )
194
+ raise ValueError("Unrecognized svd_solver='{0}'".format(self._fit_svd_solver))
183
195
 
184
- def _onedal_gpu_supported(self, method_name, *data):
185
- if method_name == 'fit':
186
- return self._fit_svd_solver == 'full'
187
- elif method_name == 'transform':
188
- return hasattr(self, '_onedal_estimator')
189
- raise RuntimeError(
190
- f'Unknown method {method_name} in {self.__class__.__name__}'
191
- )
196
+ def _onedal_supported(self, method_name, *data):
197
+ class_name = self.__class__.__name__
198
+ if method_name == "fit":
199
+ patching_status = PatchingConditionsChain(
200
+ f"sklearn.decomposition.{class_name}.{method_name}"
201
+ )
202
+ patching_status.and_conditions(
203
+ [
204
+ (
205
+ self._fit_svd_solver == "full",
206
+ f"'{self._fit_svd_solver}' SVD solver is not supported. "
207
+ "Only 'full' solver is supported.",
208
+ ),
209
+ ]
210
+ )
211
+ return patching_status
212
+ elif method_name == "transform":
213
+ patching_status = PatchingConditionsChain(
214
+ f"sklearn.decomposition.{class_name}.{method_name}"
215
+ )
216
+ patching_status.and_conditions(
217
+ [
218
+ (hasattr(self, "_onedal_estimator"), "oneDAL model was not trained"),
219
+ ]
220
+ )
221
+ return patching_status
222
+ raise RuntimeError(f"Unknown method {method_name} in {self.__class__.__name__}")
192
223
 
193
224
  def _onedal_cpu_supported(self, method_name, *data):
194
- if method_name == 'fit':
195
- return self._fit_svd_solver == 'full'
196
- elif method_name == 'transform':
197
- return hasattr(self, '_onedal_estimator')
198
- raise RuntimeError(
199
- f'Unknown method {method_name} in {self.__class__.__name__}'
200
- )
225
+ return self._onedal_supported(method_name, *data)
201
226
 
202
- def _onedal_fit(self, X, y=None, queue=None):
227
+ def _onedal_gpu_supported(self, method_name, *data):
228
+ return self._onedal_supported(method_name, *data)
203
229
 
204
- if self.n_components == 'mle' or self.n_components is None:
230
+ def _onedal_fit(self, X, y=None, queue=None):
231
+ if self.n_components == "mle" or self.n_components is None:
205
232
  onedal_n_components = min(X.shape)
206
233
  elif 0 < self.n_components < 1:
207
234
  onedal_n_components = min(X.shape)
@@ -209,9 +236,9 @@ class PCA(sklearn_PCA):
209
236
  onedal_n_components = self.n_components
210
237
 
211
238
  onedal_params = {
212
- 'n_components': onedal_n_components,
213
- 'is_deterministic': True,
214
- 'method': "precomputed",
239
+ "n_components": onedal_n_components,
240
+ "is_deterministic": True,
241
+ "method": "precomputed",
215
242
  }
216
243
  self._onedal_estimator = onedal_PCA(**onedal_params)
217
244
  self._onedal_estimator.fit(X, queue=queue)
@@ -227,12 +254,7 @@ class PCA(sklearn_PCA):
227
254
  return self._onedal_estimator.predict(X, queue)
228
255
 
229
256
  def _onedal_transform(self, X):
230
- X = _check_array(
231
- X,
232
- dtype=[np.float64, np.float32],
233
- ensure_2d=True,
234
- copy=False
235
- )
257
+ X = _check_array(X, dtype=[np.float64, np.float32], ensure_2d=True, copy=False)
236
258
 
237
259
  if hasattr(self, "n_features_in_"):
238
260
  if self.n_features_in_ != X.shape[1]:
@@ -251,10 +273,15 @@ class PCA(sklearn_PCA):
251
273
 
252
274
  # Mean center
253
275
  X_centered = X - self.mean_
254
- return dispatch(self, 'transform', {
255
- 'onedal': self.__class__._onedal_predict,
256
- 'sklearn': sklearn_PCA.transform,
257
- }, X_centered)
276
+ return dispatch(
277
+ self,
278
+ "transform",
279
+ {
280
+ "onedal": self.__class__._onedal_predict,
281
+ "sklearn": sklearn_PCA.transform,
282
+ },
283
+ X_centered,
284
+ )
258
285
 
259
286
  def transform(self, X):
260
287
  check_is_fitted(self)
@@ -310,13 +337,12 @@ class PCA(sklearn_PCA):
310
337
  self.mean_ = self._onedal_estimator.mean_
311
338
  self.singular_values_ = self._onedal_estimator.singular_values_
312
339
  self.explained_variance_ = self._onedal_estimator.explained_variance_
313
- self.explained_variance_ratio_ = \
314
- self._onedal_estimator.explained_variance_ratio_
340
+ self.explained_variance_ratio_ = self._onedal_estimator.explained_variance_ratio_
315
341
 
316
342
  if self.n_components is None:
317
343
  self.n_components_ = self._onedal_estimator.n_components_
318
- elif self.n_components == 'mle':
319
- if sklearn_check_version('0.23'):
344
+ elif self.n_components == "mle":
345
+ if sklearn_check_version("0.23"):
320
346
  self.n_components_ = _infer_dimension(
321
347
  self.explained_variance_, self.n_samples_
322
348
  )
@@ -326,23 +352,25 @@ class PCA(sklearn_PCA):
326
352
  )
327
353
  elif 0 < self.n_components < 1.0:
328
354
  ratio_cumsum = stable_cumsum(self.explained_variance_ratio_)
329
- self.n_components_ = np.searchsorted(
330
- ratio_cumsum, self.n_components, side='right') + 1
355
+ self.n_components_ = (
356
+ np.searchsorted(ratio_cumsum, self.n_components, side="right") + 1
357
+ )
331
358
  else:
332
359
  self.n_components_ = self._onedal_estimator.n_components_
333
360
 
334
361
  if self.n_components_ < n_sf_min:
335
362
  if self.explained_variance_.shape[0] == n_sf_min:
336
- self.noise_variance_ = \
337
- self.explained_variance_[self.n_components_:].mean()
363
+ self.noise_variance_ = self.explained_variance_[
364
+ self.n_components_ :
365
+ ].mean()
338
366
  else:
339
367
  self.noise_variance_ = self._onedal_estimator.noise_variance_
340
368
  else:
341
- self.noise_variance_ = 0.
342
-
343
- self.explained_variance_ = self.explained_variance_[:self.n_components_]
344
- self.explained_variance_ratio_ = \
345
- self.explained_variance_ratio_[:self.n_components_]
346
- self.components_ = \
347
- self._onedal_estimator.components_[:self.n_components_]
348
- self.singular_values_ = self.singular_values_[:self.n_components_]
369
+ self.noise_variance_ = 0.0
370
+
371
+ self.explained_variance_ = self.explained_variance_[: self.n_components_]
372
+ self.explained_variance_ratio_ = self.explained_variance_ratio_[
373
+ : self.n_components_
374
+ ]
375
+ self.components_ = self._onedal_estimator.components_[: self.n_components_]
376
+ self.singular_values_ = self.singular_values_[: self.n_components_]
@@ -1,6 +1,6 @@
1
1
  #!/usr/bin/env python
2
2
  # ===============================================================================
3
- # Copyright 2021 Intel Corporation
3
+ # Copyright 2023 Intel Corporation
4
4
  #
5
5
  # Licensed under the Apache License, Version 2.0 (the "License");
6
6
  # you may not use this file except in compliance with the License.
@@ -16,21 +16,23 @@
16
16
  # ===============================================================================
17
17
 
18
18
  import numpy as np
19
+ import pytest
19
20
  from numpy.testing import assert_allclose
20
- from sklearn.datasets import make_regression
21
- from daal4py.sklearn._utils import daal_check_version
22
21
 
22
+ from onedal.tests.utils._dataframes_support import (
23
+ _as_numpy,
24
+ _convert_to_dataframe,
25
+ get_dataframes_and_queues,
26
+ )
23
27
 
24
- def test_sklearnex_import_linear():
25
- from sklearnex.preview.linear_model import LinearRegression
26
- X = np.array([[1, 1], [1, 2], [2, 2], [2, 3]])
27
- y = np.dot(X, np.array([1, 2])) + 3
28
- linreg = LinearRegression().fit(X, y)
29
- if daal_check_version((2023, 'P', 100)):
30
- assert 'sklearnex' in linreg.__module__
31
- assert hasattr(linreg, '_onedal_estimator')
32
- else:
33
- assert 'daal4py' in linreg.__module__
34
- assert linreg.n_features_in_ == 2
35
- assert_allclose(linreg.intercept_, 3.)
36
- assert_allclose(linreg.coef_, [1., 2.])
28
+
29
+ @pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
30
+ def test_sklearnex_import(dataframe, queue):
31
+ from sklearnex.preview.decomposition import PCA
32
+
33
+ X = [[-1, -1], [-2, -1], [-3, -2], [1, 1], [2, 1], [3, 2]]
34
+ X = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
35
+ pca = PCA(n_components=2, svd_solver="full").fit(X)
36
+ assert "sklearnex" in pca.__module__
37
+ assert hasattr(pca, "_onedal_estimator")
38
+ assert_allclose(_as_numpy(pca.singular_values_), [6.30061232, 0.54980396])
@@ -1,22 +1,24 @@
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
- from .linear import LinearRegression
19
-
20
- __all__ = [
21
- 'LinearRegression'
22
- ]
1
+ # ==============================================================================
2
+ # Copyright 2023 Intel Corporation
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ # ==============================================================================
16
+
17
+ __all__ = [
18
+ "basic_statistics",
19
+ "cluster",
20
+ "decomposition",
21
+ "ensemble",
22
+ "linear_model",
23
+ "neighbors",
24
+ ]
@@ -1,4 +1,4 @@
1
- #===============================================================================
1
+ # ==============================================================================
2
2
  # Copyright 2023 Intel Corporation
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,8 +12,8 @@
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
  from .basic_statistics import BasicStatistics
18
18
 
19
- __all__ = ['BasicStatistics']
19
+ __all__ = ["BasicStatistics"]
@@ -1,4 +1,4 @@
1
- #===============================================================================
1
+ # ==============================================================================
2
2
  # Copyright 2023 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
  from onedal.spmd.basic_statistics import BasicStatistics
18
18
 
@@ -1,4 +1,4 @@
1
- #===============================================================================
1
+ # ==============================================================================
2
2
  # Copyright 2023 Intel Corporation
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,13 +12,19 @@
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
  from daal4py.sklearn._utils import daal_check_version
18
18
 
19
- if daal_check_version((2023, 'P', 200)):
19
+ from .dbscan import DBSCAN
20
+
21
+ if daal_check_version((2023, "P", 200)):
20
22
  from .kmeans import KMeans
21
23
 
22
- __all__ = ['KMeans']
24
+ __all__ = ["DBSCAN", "KMeans"]
23
25
  else:
24
- __all__ = []
26
+ # TODO:
27
+ # update versioning for DBSCAN.
28
+ __all__ = [
29
+ "DBSCAN",
30
+ ]
@@ -0,0 +1,50 @@
1
+ # ==============================================================================
2
+ # Copyright 2023 Intel Corporation
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ # ==============================================================================
16
+
17
+ from abc import ABC
18
+
19
+ from onedal.spmd.cluster import DBSCAN as onedal_DBSCAN
20
+
21
+ from ...cluster import DBSCAN as DBSCAN_Batch
22
+
23
+
24
+ class BaseDBSCANspmd(ABC):
25
+ def _onedal_dbscan(self, **onedal_params):
26
+ return onedal_DBSCAN(**onedal_params)
27
+
28
+
29
+ class DBSCAN(BaseDBSCANspmd, DBSCAN_Batch):
30
+ __doc__ = DBSCAN_Batch.__doc__
31
+
32
+ def _onedal_cpu_supported(self, method_name, *data):
33
+ # TODO:
34
+ # check which methods supported SPMD interface on CPU.
35
+ ready = super()._onedal_cpu_supported(method_name, *data)
36
+ if not ready:
37
+ raise RuntimeError(
38
+ f"Method {method_name} in {self.__class__.__name__} "
39
+ "is not supported with given inputs."
40
+ )
41
+ return ready
42
+
43
+ def _onedal_gpu_supported(self, method_name, *data):
44
+ ready = super()._onedal_gpu_supported(method_name, *data)
45
+ if not ready:
46
+ raise RuntimeError(
47
+ f"Method {method_name} in {self.__class__.__name__} "
48
+ "is not supported with given inputs."
49
+ )
50
+ return ready
@@ -1,4 +1,4 @@
1
- #===============================================================================
1
+ # ==============================================================================
2
2
  # Copyright 2023 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
  from onedal.spmd.cluster import KMeans
18
18
 
@@ -1,4 +1,4 @@
1
- #===============================================================================
1
+ # ==============================================================================
2
2
  # Copyright 2023 Intel Corporation
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,8 +12,8 @@
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
  from .pca import PCA
18
18
 
19
- __all__ = ['PCA']
19
+ __all__ = ["PCA"]
@@ -1,4 +1,4 @@
1
- #===============================================================================
1
+ # ==============================================================================
2
2
  # Copyright 2023 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
  from onedal.spmd.decomposition import PCA
18
18
 
@@ -1,4 +1,4 @@
1
- #===============================================================================
1
+ # ==============================================================================
2
2
  # Copyright 2023 Intel Corporation
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,8 +12,8 @@
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
  from .forest import RandomForestClassifier, RandomForestRegressor
18
18
 
19
- __all__ = ['RandomForestClassifier', 'RandomForestRegressor']
19
+ __all__ = ["RandomForestClassifier", "RandomForestRegressor"]