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.

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,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,17 +12,15 @@
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 abc import ABC
18
18
 
19
19
  from onedal.spmd.ensemble import RandomForestClassifier as onedal_RandomForestClassifier
20
20
  from onedal.spmd.ensemble import RandomForestRegressor as onedal_RandomForestRegressor
21
21
 
22
- from ...preview.ensemble.forest import RandomForestClassifier as \
23
- RandomForestClassifier_Batch
24
- from ...preview.ensemble.forest import RandomForestRegressor as \
25
- RandomForestRegressor_Batch
22
+ from ...ensemble import RandomForestClassifier as RandomForestClassifier_Batch
23
+ from ...ensemble import RandomForestRegressor as RandomForestRegressor_Batch
26
24
 
27
25
 
28
26
  class BaseForestSPMD(ABC):
@@ -42,16 +40,18 @@ class RandomForestClassifier(BaseForestSPMD, RandomForestClassifier_Batch):
42
40
  ready = super()._onedal_cpu_supported(method_name, *data)
43
41
  if not ready:
44
42
  raise RuntimeError(
45
- f'Method {method_name} in {self.__class__.__name__} '
46
- 'is not supported with given inputs.')
43
+ f"Method {method_name} in {self.__class__.__name__} "
44
+ "is not supported with given inputs."
45
+ )
47
46
  return ready
48
47
 
49
48
  def _onedal_gpu_supported(self, method_name, *data):
50
49
  ready = super()._onedal_gpu_supported(method_name, *data)
51
50
  if not ready:
52
51
  raise RuntimeError(
53
- f'Method {method_name} in {self.__class__.__name__} '
54
- 'is not supported with given inputs.')
52
+ f"Method {method_name} in {self.__class__.__name__} "
53
+ "is not supported with given inputs."
54
+ )
55
55
  return ready
56
56
 
57
57
 
@@ -64,14 +64,16 @@ class RandomForestRegressor(BaseForestSPMD, RandomForestRegressor_Batch):
64
64
  ready = super()._onedal_cpu_supported(method_name, *data)
65
65
  if not ready:
66
66
  raise RuntimeError(
67
- f'Method {method_name} in {self.__class__.__name__} '
68
- 'is not supported with given inputs.')
67
+ f"Method {method_name} in {self.__class__.__name__} "
68
+ "is not supported with given inputs."
69
+ )
69
70
  return ready
70
71
 
71
72
  def _onedal_gpu_supported(self, method_name, *data):
72
73
  ready = super()._onedal_gpu_supported(method_name, *data)
73
74
  if not ready:
74
75
  raise RuntimeError(
75
- f'Method {method_name} in {self.__class__.__name__} '
76
- 'is not supported with given inputs.')
76
+ f"Method {method_name} in {self.__class__.__name__} "
77
+ "is not supported with given inputs."
78
+ )
77
79
  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,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 .linear_model import LinearRegression
18
18
 
19
- __all__ = ['LinearRegression']
19
+ __all__ = ["LinearRegression"]
@@ -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.linear_model import LinearRegression
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 .neighbors import KNeighborsClassifier, KNeighborsRegressor, NearestNeighbors
18
18
 
19
- __all__ = ['KNeighborsClassifier', 'KNeighborsRegressor', 'NearestNeighbors']
19
+ __all__ = ["KNeighborsClassifier", "KNeighborsRegressor", "NearestNeighbors"]
@@ -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,12 +12,12 @@
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.neighbors import (
18
18
  KNeighborsClassifier,
19
19
  KNeighborsRegressor,
20
- NearestNeighbors
20
+ NearestNeighbors,
21
21
  )
22
22
 
23
23
  # TODO:
@@ -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,15 +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
18
  from .._utils import get_sklearnex_version
19
- if get_sklearnex_version((2021, 'P', 300)):
20
- from .svr import SVR
21
- from .svc import SVC
22
- from .nusvr import NuSVR
19
+
20
+ if get_sklearnex_version((2021, "P", 300)):
23
21
  from .nusvc import NuSVC
24
- __all__ = ['SVR', 'SVC', 'NuSVC', 'NuSVR']
22
+ from .nusvr import NuSVR
23
+ from .svc import SVC
24
+ from .svr import SVR
25
+
26
+ __all__ = ["SVR", "SVC", "NuSVC", "NuSVR"]
25
27
  else:
26
28
  from daal4py.sklearn.svm import SVC
27
- __all__ = ['SVC']
29
+
30
+ __all__ = ["SVC"]
@@ -1,4 +1,4 @@
1
- #===============================================================================
1
+ # ==============================================================================
2
2
  # Copyright 2021 Intel Corporation
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,17 +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 abc import ABC
18
- import numpy as np
19
- from daal4py.sklearn._utils import sklearn_check_version, PatchingConditionsChain
20
18
 
19
+ import numpy as np
20
+ from sklearn.calibration import CalibratedClassifierCV
21
21
  from sklearn.model_selection import StratifiedKFold
22
22
  from sklearn.preprocessing import LabelEncoder
23
- from sklearn.calibration import CalibratedClassifierCV
24
23
 
25
- from onedal.datatypes.validation import _column_or_1d
24
+ from daal4py.sklearn._utils import sklearn_check_version
25
+ from onedal.utils import _column_or_1d
26
+
27
+ from .._utils import PatchingConditionsChain
26
28
 
27
29
 
28
30
  def get_dual_coef(self):
@@ -31,7 +33,7 @@ def get_dual_coef(self):
31
33
 
32
34
  def set_dual_coef(self, value):
33
35
  self.dual_coef_ = value
34
- if hasattr(self, '_onedal_estimator'):
36
+ if hasattr(self, "_onedal_estimator"):
35
37
  self._onedal_estimator.dual_coef_ = value
36
38
  if not self._is_in_fit:
37
39
  del self._onedal_estimator._onedal_model
@@ -43,7 +45,7 @@ def get_intercept(self):
43
45
 
44
46
  def set_intercept(self, value):
45
47
  self._intercept_ = value
46
- if hasattr(self, '_onedal_estimator'):
48
+ if hasattr(self, "_onedal_estimator"):
47
49
  self._onedal_estimator.intercept_ = value
48
50
  if not self._is_in_fit:
49
51
  del self._onedal_estimator._onedal_model
@@ -51,31 +53,37 @@ def set_intercept(self, value):
51
53
 
52
54
  class BaseSVM(ABC):
53
55
  def _onedal_gpu_supported(self, method_name, *data):
54
- patching_status = PatchingConditionsChain(f'sklearn.{method_name}')
55
- patching_status.and_conditions([
56
- (False, 'GPU offloading is not supported.')
57
- ])
58
- return patching_status.get_status(logs=True)
56
+ patching_status = PatchingConditionsChain(f"sklearn.{method_name}")
57
+ patching_status.and_conditions([(False, "GPU offloading is not supported.")])
58
+ return patching_status
59
59
 
60
60
  def _onedal_cpu_supported(self, method_name, *data):
61
61
  class_name = self.__class__.__name__
62
62
  patching_status = PatchingConditionsChain(
63
- f'sklearn.svm.{class_name}.{method_name}')
64
- if method_name == 'fit':
65
- patching_status.and_conditions([
66
- (self.kernel in ['linear', 'rbf', 'poly', 'sigmoid'],
67
- f'Kernel is "{self.kernel}" while '
68
- '"linear", "rbf", "poly" and "sigmoid" are only supported.')
69
- ])
70
- return patching_status.get_status(logs=True)
71
- inference_methods = ['predict'] if class_name.endswith('R') \
72
- else ['predict', 'predict_proba', 'decision_function']
63
+ f"sklearn.svm.{class_name}.{method_name}"
64
+ )
65
+ if method_name == "fit":
66
+ patching_status.and_conditions(
67
+ [
68
+ (
69
+ self.kernel in ["linear", "rbf", "poly", "sigmoid"],
70
+ f'Kernel is "{self.kernel}" while '
71
+ '"linear", "rbf", "poly" and "sigmoid" are only supported.',
72
+ )
73
+ ]
74
+ )
75
+ return patching_status
76
+ inference_methods = (
77
+ ["predict"]
78
+ if class_name.endswith("R")
79
+ else ["predict", "predict_proba", "decision_function"]
80
+ )
73
81
  if method_name in inference_methods:
74
- patching_status.and_conditions([
75
- (hasattr(self, '_onedal_estimator'), 'oneDAL model was not trained.')
76
- ])
77
- return patching_status.get_status(logs=True)
78
- raise RuntimeError(f'Unknown method {method_name} in {class_name}')
82
+ patching_status.and_conditions(
83
+ [(hasattr(self, "_onedal_estimator"), "oneDAL model was not trained.")]
84
+ )
85
+ return patching_status
86
+ raise RuntimeError(f"Unknown method {method_name} in {class_name}")
79
87
 
80
88
 
81
89
  class BaseSVC(BaseSVM):
@@ -92,38 +100,30 @@ class BaseSVC(BaseSVM):
92
100
  return recip_freq[le.transform(classes)]
93
101
 
94
102
  def _fit_proba(self, X, y, sample_weight=None, queue=None):
95
- from .._config import get_config, config_context
96
-
97
103
  params = self.get_params()
98
104
  params["probability"] = False
99
- params["decision_function_shape"] = 'ovr'
105
+ params["decision_function_shape"] = "ovr"
100
106
  clf_base = self.__class__(**params)
101
107
 
102
- # We use stock metaestimators below, so the only way
103
- # to pass a queue is using config_context.
104
- cfg = get_config()
105
- cfg['target_offload'] = queue
106
- with config_context(**cfg):
107
- try:
108
- n_splits = 5
109
- n_jobs = n_splits if queue is None or queue.sycl_device.is_cpu else 1
110
- cv = StratifiedKFold(
111
- n_splits=n_splits,
112
- shuffle=True,
113
- random_state=self.random_state)
114
- if sklearn_check_version("0.24"):
115
- self.clf_prob = CalibratedClassifierCV(
116
- clf_base, ensemble=False, cv=cv, method='sigmoid',
117
- n_jobs=n_jobs)
118
- else:
119
- self.clf_prob = CalibratedClassifierCV(
120
- clf_base, cv=cv, method='sigmoid')
121
- self.clf_prob.fit(X, y, sample_weight)
122
- except ValueError:
123
- clf_base = clf_base.fit(X, y, sample_weight)
108
+ try:
109
+ n_splits = 5
110
+ n_jobs = n_splits if queue is None or queue.sycl_device.is_cpu else 1
111
+ cv = StratifiedKFold(
112
+ n_splits=n_splits, shuffle=True, random_state=self.random_state
113
+ )
114
+ if sklearn_check_version("0.24"):
124
115
  self.clf_prob = CalibratedClassifierCV(
125
- clf_base, cv="prefit", method='sigmoid')
126
- self.clf_prob.fit(X, y, sample_weight)
116
+ clf_base, ensemble=False, cv=cv, method="sigmoid", n_jobs=n_jobs
117
+ )
118
+ else:
119
+ self.clf_prob = CalibratedClassifierCV(clf_base, cv=cv, method="sigmoid")
120
+ self.clf_prob.fit(X, y, sample_weight)
121
+ except ValueError:
122
+ clf_base = clf_base.fit(X, y, sample_weight)
123
+ self.clf_prob = CalibratedClassifierCV(
124
+ clf_base, cv="prefit", method="sigmoid"
125
+ )
126
+ self.clf_prob.fit(X, y, sample_weight)
127
127
 
128
128
  def _save_attributes(self):
129
129
  self.support_vectors_ = self._onedal_estimator.support_vectors_
@@ -157,7 +157,7 @@ class BaseSVC(BaseSVM):
157
157
 
158
158
  if sklearn_check_version("1.1"):
159
159
  length = int(len(self.classes_) * (len(self.classes_) - 1) / 2)
160
- self.n_iter_ = np.full((length, ), self._onedal_estimator.n_iter_)
160
+ self.n_iter_ = np.full((length,), self._onedal_estimator.n_iter_)
161
161
 
162
162
 
163
163
  class BaseSVR(BaseSVM):
@@ -1,4 +1,4 @@
1
- #===============================================================================
1
+ # ==============================================================================
2
2
  # Copyright 2021 Intel Corporation
3
3
  #
4
4
  # Licensed under the Apache License, Version 2.0 (the "License");
@@ -12,16 +12,18 @@
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
+
17
+ from sklearn.exceptions import NotFittedError
18
+ from sklearn.svm import NuSVC as sklearn_NuSVC
19
+ from sklearn.utils.validation import _deprecate_positional_args
16
20
 
17
21
  from daal4py.sklearn._utils import sklearn_check_version
18
- from ._common import BaseSVC
22
+
19
23
  from .._device_offload import dispatch, wrap_output_data
24
+ from ._common import BaseSVC
20
25
 
21
- from sklearn.svm import NuSVC as sklearn_NuSVC
22
- from sklearn.utils.validation import _deprecate_positional_args
23
- from sklearn.exceptions import NotFittedError
24
- if sklearn_check_version('1.0'):
26
+ if sklearn_check_version("1.0"):
25
27
  from sklearn.utils.metaestimators import available_if
26
28
 
27
29
  from onedal.svm import NuSVC as onedal_NuSVC
@@ -30,21 +32,46 @@ from onedal.svm import NuSVC as onedal_NuSVC
30
32
  class NuSVC(sklearn_NuSVC, BaseSVC):
31
33
  __doc__ = sklearn_NuSVC.__doc__
32
34
 
33
- if sklearn_check_version('1.2'):
35
+ if sklearn_check_version("1.2"):
34
36
  _parameter_constraints: dict = {**sklearn_NuSVC._parameter_constraints}
35
37
 
36
38
  @_deprecate_positional_args
37
- def __init__(self, *, nu=0.5, kernel='rbf', degree=3, gamma='scale',
38
- coef0=0.0, shrinking=True, probability=False,
39
- tol=1e-3, cache_size=200, class_weight=None,
40
- verbose=False, max_iter=-1, decision_function_shape='ovr',
41
- break_ties=False, random_state=None):
39
+ def __init__(
40
+ self,
41
+ *,
42
+ nu=0.5,
43
+ kernel="rbf",
44
+ degree=3,
45
+ gamma="scale",
46
+ coef0=0.0,
47
+ shrinking=True,
48
+ probability=False,
49
+ tol=1e-3,
50
+ cache_size=200,
51
+ class_weight=None,
52
+ verbose=False,
53
+ max_iter=-1,
54
+ decision_function_shape="ovr",
55
+ break_ties=False,
56
+ random_state=None,
57
+ ):
42
58
  super().__init__(
43
- nu=nu, kernel=kernel, degree=degree, gamma=gamma, coef0=coef0,
44
- shrinking=shrinking, probability=probability, tol=tol, cache_size=cache_size,
45
- class_weight=class_weight, verbose=verbose, max_iter=max_iter,
46
- decision_function_shape=decision_function_shape, break_ties=break_ties,
47
- random_state=random_state)
59
+ nu=nu,
60
+ kernel=kernel,
61
+ degree=degree,
62
+ gamma=gamma,
63
+ coef0=coef0,
64
+ shrinking=shrinking,
65
+ probability=probability,
66
+ tol=tol,
67
+ cache_size=cache_size,
68
+ class_weight=class_weight,
69
+ verbose=verbose,
70
+ max_iter=max_iter,
71
+ decision_function_shape=decision_function_shape,
72
+ break_ties=break_ties,
73
+ random_state=random_state,
74
+ )
48
75
 
49
76
  def fit(self, X, y, sample_weight=None):
50
77
  """
@@ -84,10 +111,17 @@ class NuSVC(sklearn_NuSVC, BaseSVC):
84
111
  self._validate_params()
85
112
  if sklearn_check_version("1.0"):
86
113
  self._check_feature_names(X, reset=True)
87
- dispatch(self, 'fit', {
88
- 'onedal': self.__class__._onedal_fit,
89
- 'sklearn': sklearn_NuSVC.fit,
90
- }, X, y, sample_weight)
114
+ dispatch(
115
+ self,
116
+ "fit",
117
+ {
118
+ "onedal": self.__class__._onedal_fit,
119
+ "sklearn": sklearn_NuSVC.fit,
120
+ },
121
+ X,
122
+ y,
123
+ sample_weight,
124
+ )
91
125
 
92
126
  return self
93
127
 
@@ -111,12 +145,18 @@ class NuSVC(sklearn_NuSVC, BaseSVC):
111
145
  """
112
146
  if sklearn_check_version("1.0"):
113
147
  self._check_feature_names(X, reset=False)
114
- return dispatch(self, 'predict', {
115
- 'onedal': self.__class__._onedal_predict,
116
- 'sklearn': sklearn_NuSVC.predict,
117
- }, X)
148
+ return dispatch(
149
+ self,
150
+ "predict",
151
+ {
152
+ "onedal": self.__class__._onedal_predict,
153
+ "sklearn": sklearn_NuSVC.predict,
154
+ },
155
+ X,
156
+ )
157
+
158
+ if sklearn_check_version("1.0"):
118
159
 
119
- if sklearn_check_version('1.0'):
120
160
  @available_if(sklearn_NuSVC._check_proba)
121
161
  def predict_proba(self, X):
122
162
  """
@@ -146,7 +186,9 @@ class NuSVC(sklearn_NuSVC, BaseSVC):
146
186
  datasets.
147
187
  """
148
188
  return self._predict_proba(X)
189
+
149
190
  else:
191
+
150
192
  @property
151
193
  def predict_proba(self):
152
194
  self._check_proba()
@@ -156,38 +198,50 @@ class NuSVC(sklearn_NuSVC, BaseSVC):
156
198
  def _predict_proba(self, X):
157
199
  if sklearn_check_version("1.0"):
158
200
  self._check_feature_names(X, reset=False)
159
- sklearn_pred_proba = (sklearn_NuSVC.predict_proba
160
- if sklearn_check_version("1.0")
161
- else sklearn_NuSVC._predict_proba)
162
-
163
- return dispatch(self, 'predict_proba', {
164
- 'onedal': self.__class__._onedal_predict_proba,
165
- 'sklearn': sklearn_pred_proba,
166
- }, X)
201
+ sklearn_pred_proba = (
202
+ sklearn_NuSVC.predict_proba
203
+ if sklearn_check_version("1.0")
204
+ else sklearn_NuSVC._predict_proba
205
+ )
206
+
207
+ return dispatch(
208
+ self,
209
+ "predict_proba",
210
+ {
211
+ "onedal": self.__class__._onedal_predict_proba,
212
+ "sklearn": sklearn_pred_proba,
213
+ },
214
+ X,
215
+ )
167
216
 
168
217
  @wrap_output_data
169
218
  def decision_function(self, X):
170
219
  if sklearn_check_version("1.0"):
171
220
  self._check_feature_names(X, reset=False)
172
- return dispatch(self, 'decision_function', {
173
- 'onedal': self.__class__._onedal_decision_function,
174
- 'sklearn': sklearn_NuSVC.decision_function,
175
- }, X)
221
+ return dispatch(
222
+ self,
223
+ "decision_function",
224
+ {
225
+ "onedal": self.__class__._onedal_decision_function,
226
+ "sklearn": sklearn_NuSVC.decision_function,
227
+ },
228
+ X,
229
+ )
176
230
 
177
231
  def _onedal_fit(self, X, y, sample_weight=None, queue=None):
178
232
  onedal_params = {
179
- 'nu': self.nu,
180
- 'kernel': self.kernel,
181
- 'degree': self.degree,
182
- 'gamma': self.gamma,
183
- 'coef0': self.coef0,
184
- 'tol': self.tol,
185
- 'shrinking': self.shrinking,
186
- 'cache_size': self.cache_size,
187
- 'max_iter': self.max_iter,
188
- 'class_weight': self.class_weight,
189
- 'break_ties': self.break_ties,
190
- 'decision_function_shape': self.decision_function_shape,
233
+ "nu": self.nu,
234
+ "kernel": self.kernel,
235
+ "degree": self.degree,
236
+ "gamma": self.gamma,
237
+ "coef0": self.coef0,
238
+ "tol": self.tol,
239
+ "shrinking": self.shrinking,
240
+ "cache_size": self.cache_size,
241
+ "max_iter": self.max_iter,
242
+ "class_weight": self.class_weight,
243
+ "break_ties": self.break_ties,
244
+ "decision_function_shape": self.decision_function_shape,
191
245
  }
192
246
 
193
247
  self._onedal_estimator = onedal_NuSVC(**onedal_params)
@@ -201,15 +255,16 @@ class NuSVC(sklearn_NuSVC, BaseSVC):
201
255
  return self._onedal_estimator.predict(X, queue=queue)
202
256
 
203
257
  def _onedal_predict_proba(self, X, queue=None):
204
- if getattr(self, 'clf_prob', None) is None:
258
+ if getattr(self, "clf_prob", None) is None:
205
259
  raise NotFittedError(
206
- "predict_proba is not available when fitted with probability=False")
207
- from .._config import get_config, config_context
260
+ "predict_proba is not available when fitted with probability=False"
261
+ )
262
+ from .._config import config_context, get_config
208
263
 
209
264
  # We use stock metaestimators below, so the only way
210
265
  # to pass a queue is using config_context.
211
266
  cfg = get_config()
212
- cfg['target_offload'] = queue
267
+ cfg["target_offload"] = queue
213
268
  with config_context(**cfg):
214
269
  return self.clf_prob.predict_proba(X)
215
270