scikit-learn-intelex 2025.4.0__py313-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 (259) hide show
  1. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/__init__.py +73 -0
  2. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/__main__.py +58 -0
  3. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/_daal4py.cp313-win_amd64.pyd +0 -0
  4. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/doc/third-party-programs.txt +424 -0
  5. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/mb/__init__.py +19 -0
  6. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/mb/model_builders.py +377 -0
  7. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/mpi_transceiver.cp313-win_amd64.pyd +0 -0
  8. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/__init__.py +40 -0
  9. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/_n_jobs_support.py +248 -0
  10. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/_utils.py +245 -0
  11. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/cluster/__init__.py +20 -0
  12. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/cluster/dbscan.py +165 -0
  13. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/cluster/k_means.py +597 -0
  14. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/cluster/tests/test_dbscan.py +109 -0
  15. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/decomposition/__init__.py +19 -0
  16. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/decomposition/_pca.py +524 -0
  17. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/AdaBoostClassifier.py +196 -0
  18. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/GBTDAAL.py +337 -0
  19. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/__init__.py +27 -0
  20. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/_forest.py +1397 -0
  21. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/tests/test_decision_forest.py +206 -0
  22. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/__init__.py +29 -0
  23. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/_coordinate_descent.py +848 -0
  24. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/_linear.py +272 -0
  25. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/_ridge.py +325 -0
  26. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/coordinate_descent.py +17 -0
  27. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/linear.py +17 -0
  28. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/logistic_loss.py +195 -0
  29. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/logistic_path.py +1026 -0
  30. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/ridge.py +17 -0
  31. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/tests/test_linear.py +208 -0
  32. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/tests/test_ridge.py +69 -0
  33. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/manifold/__init__.py +19 -0
  34. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/manifold/_t_sne.py +405 -0
  35. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/metrics/__init__.py +20 -0
  36. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/metrics/_pairwise.py +236 -0
  37. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/metrics/_ranking.py +210 -0
  38. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/model_selection/__init__.py +19 -0
  39. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/model_selection/_split.py +309 -0
  40. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/model_selection/tests/test_split.py +56 -0
  41. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/__init__.py +0 -0
  42. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/dispatcher.py +232 -0
  43. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/tests/_models_info.py +161 -0
  44. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/tests/test_monkeypatch.py +71 -0
  45. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/tests/test_patching.py +90 -0
  46. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/tests/utils/_launch_algorithms.py +117 -0
  47. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/__init__.py +21 -0
  48. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/_base.py +503 -0
  49. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/_classification.py +139 -0
  50. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/_regression.py +74 -0
  51. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/_unsupervised.py +55 -0
  52. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/tests/test_kneighbors.py +113 -0
  53. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/svm/__init__.py +19 -0
  54. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/svm/svm.py +734 -0
  55. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/utils/__init__.py +21 -0
  56. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/utils/base.py +75 -0
  57. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/utils/tests/test_utils.py +51 -0
  58. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/daal4py/sklearn/utils/validation.py +696 -0
  59. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/__init__.py +83 -0
  60. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/_config.py +54 -0
  61. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/_device_offload.py +204 -0
  62. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/_onedal_py_dpc.cp313-win_amd64.pyd +0 -0
  63. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/_onedal_py_host.cp313-win_amd64.pyd +0 -0
  64. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/basic_statistics/__init__.py +20 -0
  65. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/basic_statistics/basic_statistics.py +107 -0
  66. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/basic_statistics/incremental_basic_statistics.py +175 -0
  67. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/basic_statistics/tests/test_basic_statistics.py +242 -0
  68. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/basic_statistics/tests/test_incremental_basic_statistics.py +279 -0
  69. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/basic_statistics/tests/utils.py +50 -0
  70. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/cluster/__init__.py +27 -0
  71. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/cluster/dbscan.py +105 -0
  72. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/cluster/kmeans.py +557 -0
  73. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/cluster/kmeans_init.py +112 -0
  74. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/cluster/tests/test_dbscan.py +125 -0
  75. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/cluster/tests/test_kmeans.py +88 -0
  76. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/cluster/tests/test_kmeans_init.py +93 -0
  77. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/common/_base.py +38 -0
  78. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/common/_estimator_checks.py +47 -0
  79. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/common/_mixin.py +62 -0
  80. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/common/_policy.py +55 -0
  81. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/common/_spmd_policy.py +30 -0
  82. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/common/hyperparameters.py +125 -0
  83. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/common/tests/test_policy.py +76 -0
  84. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/common/tests/test_sycl.py +128 -0
  85. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/covariance/__init__.py +20 -0
  86. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/covariance/covariance.py +122 -0
  87. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/covariance/incremental_covariance.py +161 -0
  88. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/covariance/tests/test_covariance.py +50 -0
  89. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/covariance/tests/test_incremental_covariance.py +190 -0
  90. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/datatypes/__init__.py +19 -0
  91. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/datatypes/_data_conversion.py +121 -0
  92. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/datatypes/tests/common.py +126 -0
  93. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/datatypes/tests/test_data.py +475 -0
  94. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/decomposition/__init__.py +20 -0
  95. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/decomposition/incremental_pca.py +214 -0
  96. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/decomposition/pca.py +186 -0
  97. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/decomposition/tests/test_incremental_pca.py +285 -0
  98. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/ensemble/__init__.py +29 -0
  99. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/ensemble/forest.py +736 -0
  100. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/ensemble/tests/test_random_forest.py +97 -0
  101. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/linear_model/__init__.py +27 -0
  102. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/linear_model/incremental_linear_model.py +292 -0
  103. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/linear_model/linear_model.py +325 -0
  104. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/linear_model/logistic_regression.py +247 -0
  105. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_incremental_linear_regression.py +213 -0
  106. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_incremental_ridge_regression.py +171 -0
  107. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_linear_regression.py +259 -0
  108. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_logistic_regression.py +95 -0
  109. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_ridge.py +95 -0
  110. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/neighbors/__init__.py +19 -0
  111. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/neighbors/neighbors.py +763 -0
  112. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/neighbors/tests/test_knn_classification.py +49 -0
  113. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/primitives/__init__.py +27 -0
  114. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/primitives/get_tree.py +25 -0
  115. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/primitives/kernel_functions.py +152 -0
  116. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/primitives/tests/test_kernel_functions.py +159 -0
  117. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/svm/__init__.py +19 -0
  118. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/svm/svm.py +556 -0
  119. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/svm/tests/test_csr_svm.py +351 -0
  120. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/svm/tests/test_nusvc.py +204 -0
  121. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/svm/tests/test_nusvr.py +210 -0
  122. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/svm/tests/test_svc.py +176 -0
  123. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/svm/tests/test_svr.py +243 -0
  124. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/tests/test_common.py +57 -0
  125. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/tests/utils/_dataframes_support.py +162 -0
  126. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/tests/utils/_device_selection.py +102 -0
  127. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/utils/__init__.py +49 -0
  128. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/utils/_array_api.py +81 -0
  129. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/utils/_dpep_helpers.py +56 -0
  130. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/utils/tests/test_validation.py +142 -0
  131. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/onedal/utils/validation.py +464 -0
  132. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/__init__.py +66 -0
  133. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/__main__.py +58 -0
  134. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/_config.py +116 -0
  135. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/_device_offload.py +126 -0
  136. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/_utils.py +177 -0
  137. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/basic_statistics/__init__.py +20 -0
  138. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/basic_statistics/basic_statistics.py +261 -0
  139. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/basic_statistics/incremental_basic_statistics.py +352 -0
  140. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/basic_statistics/tests/test_basic_statistics.py +405 -0
  141. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/basic_statistics/tests/test_incremental_basic_statistics.py +455 -0
  142. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/cluster/__init__.py +20 -0
  143. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/cluster/dbscan.py +197 -0
  144. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/cluster/k_means.py +397 -0
  145. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/cluster/tests/test_dbscan.py +38 -0
  146. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/cluster/tests/test_kmeans.py +157 -0
  147. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/conftest.py +82 -0
  148. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/covariance/__init__.py +19 -0
  149. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/covariance/incremental_covariance.py +405 -0
  150. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/covariance/tests/test_incremental_covariance.py +287 -0
  151. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/decomposition/__init__.py +19 -0
  152. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/decomposition/pca.py +427 -0
  153. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/decomposition/tests/test_pca.py +58 -0
  154. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/dispatcher.py +534 -0
  155. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/doc/third-party-programs.txt +424 -0
  156. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/ensemble/__init__.py +29 -0
  157. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/ensemble/_forest.py +2029 -0
  158. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/ensemble/tests/test_forest.py +140 -0
  159. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/glob/__main__.py +72 -0
  160. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/glob/dispatcher.py +101 -0
  161. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/linear_model/__init__.py +32 -0
  162. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/linear_model/coordinate_descent.py +30 -0
  163. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/linear_model/incremental_linear.py +495 -0
  164. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/linear_model/incremental_ridge.py +432 -0
  165. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/linear_model/linear.py +346 -0
  166. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/linear_model/logistic_regression.py +415 -0
  167. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/linear_model/ridge.py +390 -0
  168. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_incremental_linear.py +267 -0
  169. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_incremental_ridge.py +214 -0
  170. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_linear.py +142 -0
  171. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_logreg.py +134 -0
  172. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_ridge.py +256 -0
  173. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/manifold/__init__.py +19 -0
  174. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/manifold/t_sne.py +26 -0
  175. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/manifold/tests/test_tsne.py +250 -0
  176. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/metrics/__init__.py +23 -0
  177. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/metrics/pairwise.py +22 -0
  178. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/metrics/ranking.py +20 -0
  179. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/metrics/tests/test_metrics.py +39 -0
  180. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/model_selection/__init__.py +21 -0
  181. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/model_selection/split.py +22 -0
  182. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/model_selection/tests/test_model_selection.py +34 -0
  183. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/neighbors/__init__.py +27 -0
  184. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/neighbors/_lof.py +236 -0
  185. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/neighbors/common.py +310 -0
  186. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/neighbors/knn_classification.py +231 -0
  187. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/neighbors/knn_regression.py +207 -0
  188. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/neighbors/knn_unsupervised.py +178 -0
  189. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/neighbors/tests/test_neighbors.py +82 -0
  190. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/preview/__init__.py +17 -0
  191. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/preview/covariance/__init__.py +19 -0
  192. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/preview/covariance/covariance.py +142 -0
  193. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/preview/covariance/tests/test_covariance.py +66 -0
  194. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/__init__.py +19 -0
  195. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/incremental_pca.py +244 -0
  196. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/tests/test_incremental_pca.py +336 -0
  197. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/__init__.py +25 -0
  198. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/__init__.py +20 -0
  199. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/basic_statistics.py +21 -0
  200. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/incremental_basic_statistics.py +30 -0
  201. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/tests/test_basic_statistics_spmd.py +107 -0
  202. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/tests/test_incremental_basic_statistics_spmd.py +306 -0
  203. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/__init__.py +30 -0
  204. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/dbscan.py +50 -0
  205. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/kmeans.py +21 -0
  206. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/tests/test_dbscan_spmd.py +97 -0
  207. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/tests/test_kmeans_spmd.py +173 -0
  208. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/__init__.py +20 -0
  209. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/covariance.py +21 -0
  210. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/incremental_covariance.py +37 -0
  211. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/tests/test_covariance_spmd.py +107 -0
  212. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/tests/test_incremental_covariance_spmd.py +184 -0
  213. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/__init__.py +20 -0
  214. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/incremental_pca.py +30 -0
  215. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/pca.py +21 -0
  216. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/tests/test_incremental_pca_spmd.py +269 -0
  217. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/tests/test_pca_spmd.py +128 -0
  218. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/ensemble/__init__.py +19 -0
  219. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/ensemble/forest.py +71 -0
  220. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/ensemble/tests/test_forest_spmd.py +265 -0
  221. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/__init__.py +21 -0
  222. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/incremental_linear_model.py +35 -0
  223. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/linear_model.py +21 -0
  224. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/logistic_regression.py +21 -0
  225. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/tests/test_incremental_linear_spmd.py +331 -0
  226. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/tests/test_linear_regression_spmd.py +145 -0
  227. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/tests/test_logistic_regression_spmd.py +162 -0
  228. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/neighbors/__init__.py +19 -0
  229. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/neighbors/neighbors.py +25 -0
  230. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/spmd/neighbors/tests/test_neighbors_spmd.py +288 -0
  231. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/svm/__init__.py +29 -0
  232. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/svm/_common.py +339 -0
  233. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/svm/nusvc.py +371 -0
  234. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/svm/nusvr.py +170 -0
  235. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/svm/svc.py +399 -0
  236. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/svm/svr.py +167 -0
  237. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/svm/tests/test_svm.py +93 -0
  238. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/tests/test_common.py +491 -0
  239. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/tests/test_config.py +123 -0
  240. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/tests/test_hyperparameters.py +43 -0
  241. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/tests/test_memory_usage.py +347 -0
  242. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/tests/test_monkeypatch.py +269 -0
  243. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/tests/test_n_jobs_support.py +108 -0
  244. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/tests/test_parallel.py +48 -0
  245. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/tests/test_patching.py +377 -0
  246. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability.py +326 -0
  247. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/tests/utils/__init__.py +48 -0
  248. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/tests/utils/base.py +436 -0
  249. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/tests/utils/spmd.py +198 -0
  250. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/utils/__init__.py +19 -0
  251. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/utils/_array_api.py +82 -0
  252. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/utils/parallel.py +59 -0
  253. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/utils/tests/test_validation.py +238 -0
  254. scikit_learn_intelex-2025.4.0.data/data/Lib/site-packages/sklearnex/utils/validation.py +208 -0
  255. scikit_learn_intelex-2025.4.0.dist-info/LICENSE.txt +202 -0
  256. scikit_learn_intelex-2025.4.0.dist-info/METADATA +192 -0
  257. scikit_learn_intelex-2025.4.0.dist-info/RECORD +259 -0
  258. scikit_learn_intelex-2025.4.0.dist-info/WHEEL +5 -0
  259. scikit_learn_intelex-2025.4.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,464 @@
1
+ # ==============================================================================
2
+ # Copyright 2021 Intel Corporation
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ # ==============================================================================
16
+
17
+ import warnings
18
+ from collections.abc import Sequence
19
+ from numbers import Integral
20
+
21
+ import numpy as np
22
+ from scipy import sparse as sp
23
+
24
+ if np.lib.NumpyVersion(np.__version__) >= np.lib.NumpyVersion("2.0.0a0"):
25
+ # numpy_version >= 2.0
26
+ from numpy.exceptions import VisibleDeprecationWarning
27
+ else:
28
+ # numpy_version < 2.0
29
+ from numpy import VisibleDeprecationWarning
30
+
31
+ from sklearn.preprocessing import LabelEncoder
32
+ from sklearn.utils.validation import check_array
33
+
34
+ from daal4py.sklearn.utils.validation import (
35
+ _assert_all_finite as _daal4py_assert_all_finite,
36
+ )
37
+ from onedal import _backend
38
+ from onedal.common._policy import _get_policy
39
+ from onedal.datatypes import to_table
40
+
41
+
42
+ class DataConversionWarning(UserWarning):
43
+ """Warning used to notify implicit data conversions happening in the code."""
44
+
45
+
46
+ def _is_arraylike(x):
47
+ """Returns whether the input is array-like."""
48
+ return hasattr(x, "__len__") or hasattr(x, "shape") or hasattr(x, "__array__")
49
+
50
+
51
+ def _is_arraylike_not_scalar(array):
52
+ """Return True if array is array-like and not a scalar"""
53
+ return _is_arraylike(array) and not np.isscalar(array)
54
+
55
+
56
+ def _column_or_1d(y, warn=False):
57
+ y = np.asarray(y)
58
+
59
+ # TODO: Convert this kind of arrays to a table like in daal4py
60
+ if not y.flags.aligned and not y.flags.writeable:
61
+ y = np.array(y.tolist())
62
+
63
+ shape = np.shape(y)
64
+ if len(shape) == 1:
65
+ return np.ravel(y)
66
+ if len(shape) == 2 and shape[1] == 1:
67
+ if warn:
68
+ warnings.warn(
69
+ "A column-vector y was passed when a 1d array was"
70
+ " expected. Please change the shape of y to "
71
+ "(n_samples, ), for example using ravel().",
72
+ DataConversionWarning,
73
+ stacklevel=2,
74
+ )
75
+ return np.ravel(y)
76
+
77
+ raise ValueError(
78
+ "y should be a 1d array, " "got an array of shape {} instead.".format(shape)
79
+ )
80
+
81
+
82
+ def _compute_class_weight(class_weight, classes, y):
83
+ if set(y) - set(classes):
84
+ raise ValueError("classes should include all valid labels that can " "be in y")
85
+ if class_weight is None or len(class_weight) == 0:
86
+ weight = np.ones(classes.shape[0], dtype=np.float64, order="C")
87
+ elif class_weight == "balanced":
88
+ y_ = _column_or_1d(y)
89
+ classes, _ = np.unique(y_, return_inverse=True)
90
+
91
+ le = LabelEncoder()
92
+ y_ind = le.fit_transform(y_)
93
+ if not all(np.in1d(classes, le.classes_)):
94
+ raise ValueError("classes should have valid labels that are in y")
95
+
96
+ y_bin = np.bincount(y_ind).astype(np.float64)
97
+ weight = len(y_) / (len(le.classes_) * y_bin)
98
+ else:
99
+ # user-defined dictionary
100
+ weight = np.ones(classes.shape[0], dtype=np.float64, order="C")
101
+ if not isinstance(class_weight, dict):
102
+ raise ValueError(
103
+ "class_weight must be dict, 'balanced', or None,"
104
+ " got: %r" % class_weight
105
+ )
106
+ for c in class_weight:
107
+ i = np.searchsorted(classes, c)
108
+ if i >= len(classes) or classes[i] != c:
109
+ raise ValueError("Class label {} not present.".format(c))
110
+ weight[i] = class_weight[c]
111
+
112
+ return weight
113
+
114
+
115
+ def _validate_targets(y, class_weight, dtype):
116
+ y_ = _column_or_1d(y, warn=True)
117
+ _check_classification_targets(y)
118
+ classes, y = np.unique(y_, return_inverse=True)
119
+ class_weight_res = _compute_class_weight(class_weight, classes=classes, y=y_)
120
+
121
+ if len(classes) < 2:
122
+ raise ValueError(
123
+ "The number of classes has to be greater than one; got %d"
124
+ " class" % len(classes)
125
+ )
126
+
127
+ return np.asarray(y, dtype=dtype, order="C"), class_weight_res, classes
128
+
129
+
130
+ def _check_array(
131
+ array,
132
+ dtype="numeric",
133
+ accept_sparse=False,
134
+ order=None,
135
+ copy=False,
136
+ force_all_finite=True,
137
+ ensure_2d=True,
138
+ accept_large_sparse=True,
139
+ ):
140
+ if force_all_finite:
141
+ if sp.issparse(array):
142
+ if hasattr(array, "data"):
143
+ _daal4py_assert_all_finite(array.data)
144
+ force_all_finite = False
145
+ else:
146
+ _daal4py_assert_all_finite(array)
147
+ force_all_finite = False
148
+ array = check_array(
149
+ array=array,
150
+ dtype=dtype,
151
+ accept_sparse=accept_sparse,
152
+ order=order,
153
+ copy=copy,
154
+ force_all_finite=force_all_finite,
155
+ ensure_2d=ensure_2d,
156
+ accept_large_sparse=accept_large_sparse,
157
+ )
158
+
159
+ if sp.issparse(array):
160
+ return array
161
+ return array
162
+
163
+
164
+ def _check_X_y(
165
+ X,
166
+ y,
167
+ dtype="numeric",
168
+ accept_sparse=False,
169
+ order=None,
170
+ copy=False,
171
+ force_all_finite=True,
172
+ ensure_2d=True,
173
+ accept_large_sparse=True,
174
+ y_numeric=False,
175
+ accept_2d_y=False,
176
+ ):
177
+ if y is None:
178
+ raise ValueError("y cannot be None")
179
+
180
+ X = _check_array(
181
+ X,
182
+ accept_sparse=accept_sparse,
183
+ dtype=dtype,
184
+ order=order,
185
+ copy=copy,
186
+ force_all_finite=force_all_finite,
187
+ ensure_2d=ensure_2d,
188
+ accept_large_sparse=accept_large_sparse,
189
+ )
190
+
191
+ if not accept_2d_y:
192
+ y = _column_or_1d(y, warn=True)
193
+ else:
194
+ y = np.ascontiguousarray(y)
195
+
196
+ if y_numeric and y.dtype.kind == "O":
197
+ y = y.astype(np.float64)
198
+ if force_all_finite:
199
+ _daal4py_assert_all_finite(y)
200
+
201
+ lengths = [X.shape[0], y.shape[0]]
202
+ uniques = np.unique(lengths)
203
+ if len(uniques) > 1:
204
+ raise ValueError(
205
+ "Found input variables with inconsistent numbers of"
206
+ " samples: %r" % [int(length) for length in lengths]
207
+ )
208
+
209
+ return X, y
210
+
211
+
212
+ def _check_classification_targets(y):
213
+ y_type = _type_of_target(y)
214
+ if y_type not in [
215
+ "binary",
216
+ "multiclass",
217
+ "multiclass-multioutput",
218
+ "multilabel-indicator",
219
+ "multilabel-sequences",
220
+ ]:
221
+ raise ValueError("Unknown label type: %r" % y_type)
222
+
223
+
224
+ def _type_of_target(y):
225
+ is_sequence, is_array = isinstance(y, Sequence), hasattr(y, "__array__")
226
+ is_not_string, is_sparse = not isinstance(y, str), sp.issparse(y)
227
+ valid = (is_sequence or is_array or is_sparse) and is_not_string
228
+
229
+ if not valid:
230
+ raise ValueError(
231
+ "Expected array-like (array or non-string sequence), " "got %r" % y
232
+ )
233
+
234
+ sparse_pandas = y.__class__.__name__ in ["SparseSeries", "SparseArray"]
235
+ if sparse_pandas:
236
+ raise ValueError("y cannot be class 'SparseSeries' or 'SparseArray'")
237
+
238
+ if _is_multilabel(y):
239
+ return "multilabel-indicator"
240
+
241
+ # DeprecationWarning will be replaced by ValueError, see NEP 34
242
+ # https://numpy.org/neps/nep-0034-infer-dtype-is-object.html
243
+ with warnings.catch_warnings():
244
+ warnings.simplefilter("error", VisibleDeprecationWarning)
245
+ try:
246
+ y = np.asarray(y)
247
+ except VisibleDeprecationWarning:
248
+ # dtype=object should be provided explicitly for ragged arrays,
249
+ # see NEP 34
250
+ y = np.asarray(y, dtype=object)
251
+
252
+ # The old sequence of sequences format
253
+ try:
254
+ if (
255
+ not hasattr(y[0], "__array__")
256
+ and isinstance(y[0], Sequence)
257
+ and not isinstance(y[0], str)
258
+ ):
259
+ raise ValueError(
260
+ "You appear to be using a legacy multi-label data"
261
+ " representation. Sequence of sequences are no"
262
+ " longer supported; use a binary array or sparse"
263
+ " matrix instead - the MultiLabelBinarizer"
264
+ " transformer can convert to this format."
265
+ )
266
+ except IndexError:
267
+ pass
268
+
269
+ # Invalid inputs
270
+ if y.ndim > 2 or (y.dtype == object and len(y) and not isinstance(y.flat[0], str)):
271
+ return "unknown" # [[[1, 2]]] or [obj_1] and not ["label_1"]
272
+
273
+ if y.ndim == 2 and y.shape[1] == 0:
274
+ return "unknown" # [[]]
275
+
276
+ if y.ndim == 2 and y.shape[1] > 1:
277
+ suffix = "-multioutput" # [[1, 2], [1, 2]]
278
+ else:
279
+ suffix = "" # [1, 2, 3] or [[1], [2], [3]]
280
+
281
+ # check float and contains non-integer float values
282
+ if y.dtype.kind == "f" and np.any(y != y.astype(int)):
283
+ # [.1, .2, 3] or [[.1, .2, 3]] or [[1., .2]] and not [1., 2., 3.]
284
+ _daal4py_assert_all_finite(y)
285
+ return "continuous" + suffix
286
+
287
+ if (len(np.unique(y)) > 2) or (y.ndim >= 2 and len(y[0]) > 1):
288
+ return "multiclass" + suffix # [1, 2, 3] or [[1., 2., 3]] or [[1, 2]]
289
+ return "binary" # [1, 2] or [["a"], ["b"]]
290
+
291
+
292
+ def _is_integral_float(y):
293
+ return y.dtype.kind == "f" and np.all(y.astype(int) == y)
294
+
295
+
296
+ def _is_multilabel(y):
297
+ if hasattr(y, "__array__") or isinstance(y, Sequence):
298
+ # DeprecationWarning will be replaced by ValueError, see NEP 34
299
+ # https://numpy.org/neps/nep-0034-infer-dtype-is-object.html
300
+ with warnings.catch_warnings():
301
+ warnings.simplefilter("error", VisibleDeprecationWarning)
302
+ try:
303
+ y = np.asarray(y)
304
+ except VisibleDeprecationWarning:
305
+ # dtype=object should be provided explicitly for ragged arrays,
306
+ # see NEP 34
307
+ y = np.array(y, dtype=object)
308
+
309
+ if not (hasattr(y, "shape") and y.ndim == 2 and y.shape[1] > 1):
310
+ return False
311
+
312
+ if sp.issparse(y):
313
+ if isinstance(y, (sp.dok_matrix, sp.lil_matrix)):
314
+ y = y.tocsr()
315
+ return (
316
+ len(y.data) == 0
317
+ or np.unique(y.data).size == 1
318
+ and (y.dtype.kind in "biu" or _is_integral_float(np.unique(y.data)))
319
+ )
320
+ labels = np.unique(y)
321
+
322
+ return len(labels) < 3 and (y.dtype.kind in "biu" or _is_integral_float(labels))
323
+
324
+
325
+ def _check_n_features(self, X, reset):
326
+ try:
327
+ n_features = _num_features(X)
328
+ except TypeError as e:
329
+ if not reset and hasattr(self, "n_features_in_"):
330
+ raise ValueError(
331
+ "X does not contain any features, but "
332
+ f"{self.__class__.__name__} is expecting "
333
+ f"{self.n_features_in_} features"
334
+ ) from e
335
+ # If the number of features is not defined and reset=True,
336
+ # then we skip this check
337
+ return
338
+
339
+ if reset:
340
+ self.n_features_in_ = n_features
341
+ return
342
+
343
+ if not hasattr(self, "n_features_in_"):
344
+ # Skip this check if the expected number of expected input features
345
+ # was not recorded by calling fit first. This is typically the case
346
+ # for stateless transformers.
347
+ return
348
+
349
+ if n_features != self.n_features_in_:
350
+ raise ValueError(
351
+ f"X has {n_features} features, but {self.__class__.__name__} "
352
+ f"is expecting {self.n_features_in_} features as input."
353
+ )
354
+
355
+
356
+ def _num_features(X, fallback_1d=False):
357
+ if X is None:
358
+ raise ValueError("Expected array-like (array or non-string sequence), got None")
359
+ type_ = type(X)
360
+ if type_.__module__ == "builtins":
361
+ type_name = type_.__qualname__
362
+ else:
363
+ type_name = f"{type_.__module__}.{type_.__qualname__}"
364
+ message = "Unable to find the number of features from X of type " f"{type_name}"
365
+ if not hasattr(X, "__len__") and not hasattr(X, "shape"):
366
+ if not hasattr(X, "__array__"):
367
+ raise ValueError(message)
368
+ # Only convert X to a numpy array if there is no cheaper, heuristic
369
+ # option.
370
+ X = np.asarray(X)
371
+
372
+ if hasattr(X, "shape"):
373
+ ndim_thr = 1 if fallback_1d else 2
374
+ if not hasattr(X.shape, "__len__") or len(X.shape) < ndim_thr:
375
+ message += f" with shape {X.shape}"
376
+ raise ValueError(message)
377
+ if len(X.shape) <= 1:
378
+ return 1
379
+ else:
380
+ return X.shape[-1]
381
+
382
+ try:
383
+ first_sample = X[0]
384
+ except IndexError:
385
+ raise ValueError("Passed empty data.")
386
+
387
+ # Do not consider an array-like of strings or dicts to be a 2D array
388
+ if isinstance(first_sample, (str, bytes, dict)):
389
+ message += f" where the samples are of type " f"{type(first_sample).__qualname__}"
390
+ raise ValueError(message)
391
+
392
+ try:
393
+ # If X is a list of lists, for instance, we assume that all nested
394
+ # lists have the same length without checking or converting to
395
+ # a numpy array to keep this function call as cheap as possible.
396
+ if (not fallback_1d) or hasattr(first_sample, "__len__"):
397
+ return len(first_sample)
398
+ else:
399
+ return 1
400
+ except Exception as err:
401
+ raise ValueError(message) from err
402
+
403
+
404
+ def _num_samples(x):
405
+ message = "Expected sequence or array-like, got %s" % type(x)
406
+ if hasattr(x, "fit") and callable(x.fit):
407
+ # Don't get num_samples from an ensembles length!
408
+ raise TypeError(message)
409
+
410
+ if not hasattr(x, "__len__") and not hasattr(x, "shape"):
411
+ if hasattr(x, "__array__"):
412
+ x = np.asarray(x)
413
+ else:
414
+ raise TypeError(message)
415
+
416
+ if hasattr(x, "shape") and x.shape is not None:
417
+ if len(x.shape) == 0:
418
+ raise TypeError(
419
+ "Singleton array %r cannot be considered a valid collection." % x
420
+ )
421
+ # Check that shape is returning an integer or default to len
422
+ # Dask dataframes may not return numeric shape[0] value
423
+ if hasattr(x, "shape") and isinstance(x.shape[0], Integral):
424
+ return x.shape[0]
425
+
426
+ try:
427
+ return len(x)
428
+ except TypeError as type_error:
429
+ raise TypeError(message) from type_error
430
+
431
+
432
+ def _is_csr(x):
433
+ """Return True if x is scipy.sparse.csr_matrix or scipy.sparse.csr_array"""
434
+ return isinstance(x, sp.csr_matrix) or (
435
+ hasattr(sp, "csr_array") and isinstance(x, sp.csr_array)
436
+ )
437
+
438
+
439
+ def _assert_all_finite(X, allow_nan=False, input_name=""):
440
+ policy = _get_policy(None, X)
441
+ X_t = to_table(X)
442
+ params = {
443
+ "fptype": X_t.dtype,
444
+ "method": "dense",
445
+ "allow_nan": allow_nan,
446
+ }
447
+ if not _backend.finiteness_checker.compute.compute(policy, params, X_t).finite:
448
+ type_err = "infinity" if allow_nan else "NaN, infinity"
449
+ padded_input_name = input_name + " " if input_name else ""
450
+ msg_err = f"Input {padded_input_name}contains {type_err}."
451
+ raise ValueError(msg_err)
452
+
453
+
454
+ def assert_all_finite(
455
+ X,
456
+ *,
457
+ allow_nan=False,
458
+ input_name="",
459
+ ):
460
+ _assert_all_finite(
461
+ X.data if sp.issparse(X) else X,
462
+ allow_nan=allow_nan,
463
+ input_name=input_name,
464
+ )
@@ -0,0 +1,66 @@
1
+ # ==============================================================================
2
+ # Copyright 2021 Intel Corporation
3
+ # Copyright 2024 Fujitsu Limited
4
+ #
5
+ # Licensed under the Apache License, Version 2.0 (the "License");
6
+ # you may not use this file except in compliance with the License.
7
+ # You may obtain a copy of the License at
8
+ #
9
+ # http://www.apache.org/licenses/LICENSE-2.0
10
+ #
11
+ # Unless required by applicable law or agreed to in writing, software
12
+ # distributed under the License is distributed on an "AS IS" BASIS,
13
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
+ # See the License for the specific language governing permissions and
15
+ # limitations under the License.
16
+ # ==============================================================================
17
+
18
+ import os
19
+
20
+ from . import utils
21
+ from ._config import config_context, get_config, set_config
22
+ from .dispatcher import (
23
+ get_patch_map,
24
+ get_patch_names,
25
+ is_patched_instance,
26
+ patch_sklearn,
27
+ sklearn_is_patched,
28
+ unpatch_sklearn,
29
+ )
30
+
31
+ __all__ = [
32
+ "basic_statistics",
33
+ "cluster",
34
+ "config_context",
35
+ "covariance",
36
+ "decomposition",
37
+ "ensemble",
38
+ "get_config",
39
+ "get_hyperparameters",
40
+ "get_patch_map",
41
+ "get_patch_names",
42
+ "is_patched_instance",
43
+ "linear_model",
44
+ "manifold",
45
+ "metrics",
46
+ "model_selection",
47
+ "neighbors",
48
+ "patch_sklearn",
49
+ "set_config",
50
+ "sklearn_is_patched",
51
+ "svm",
52
+ "unpatch_sklearn",
53
+ "utils",
54
+ ]
55
+ onedal_iface_flag = os.environ.get("OFF_ONEDAL_IFACE", "0")
56
+ if onedal_iface_flag == "0":
57
+ from onedal import _is_spmd_backend
58
+ from onedal.common.hyperparameters import get_hyperparameters
59
+
60
+ if _is_spmd_backend:
61
+ __all__.append("spmd")
62
+
63
+
64
+ from ._utils import set_sklearn_ex_verbose
65
+
66
+ set_sklearn_ex_verbose()
@@ -0,0 +1,58 @@
1
+ # ==============================================================================
2
+ # Copyright 2021 Intel Corporation
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ # ==============================================================================
16
+
17
+ import sys
18
+
19
+ from sklearnex import patch_sklearn
20
+
21
+
22
+ def _main():
23
+ import argparse
24
+
25
+ parser = argparse.ArgumentParser(
26
+ prog="python -m sklearnex",
27
+ description="""
28
+ Run your Python script with Intel(R) Extension for
29
+ scikit-learn, optimizing solvers of
30
+ scikit-learn with Intel(R) oneAPI Data Analytics Library.
31
+ """,
32
+ formatter_class=argparse.ArgumentDefaultsHelpFormatter,
33
+ )
34
+
35
+ parser.add_argument(
36
+ "-m", action="store_true", dest="module", help="Executes following as a module"
37
+ )
38
+ parser.add_argument("name", help="Script or module name")
39
+ parser.add_argument("args", nargs=argparse.REMAINDER, help="Command line arguments")
40
+ args = parser.parse_args()
41
+
42
+ try:
43
+ import sklearn
44
+
45
+ patch_sklearn()
46
+ except ImportError:
47
+ print("Scikit-learn could not be imported. Nothing to patch")
48
+
49
+ sys.argv = [args.name] + args.args
50
+ if "_" + args.name in globals():
51
+ return globals()["_" + args.name](*args.args)
52
+ import runpy
53
+
54
+ runf = runpy.run_module if args.module else runpy.run_path
55
+ runf(args.name, run_name="__main__")
56
+
57
+
58
+ sys.exit(_main())
@@ -0,0 +1,116 @@
1
+ # ==============================================================================
2
+ # Copyright 2021 Intel Corporation
3
+ #
4
+ # Licensed under the Apache License, Version 2.0 (the "License");
5
+ # you may not use this file except in compliance with the License.
6
+ # You may obtain a copy of the License at
7
+ #
8
+ # http://www.apache.org/licenses/LICENSE-2.0
9
+ #
10
+ # Unless required by applicable law or agreed to in writing, software
11
+ # distributed under the License is distributed on an "AS IS" BASIS,
12
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
+ # See the License for the specific language governing permissions and
14
+ # limitations under the License.
15
+ # ==============================================================================
16
+
17
+ from contextlib import contextmanager
18
+ from os import environ
19
+
20
+ from sklearn import get_config as skl_get_config
21
+ from sklearn import set_config as skl_set_config
22
+
23
+ from daal4py.sklearn._utils import sklearn_check_version
24
+ from onedal._config import _get_config as onedal_get_config
25
+
26
+
27
+ def get_config():
28
+ """Retrieve current values for configuration set by :func:`set_config`
29
+ Returns
30
+ -------
31
+ config : dict
32
+ Keys are parameter names that can be passed to :func:`set_config`.
33
+ See Also
34
+ --------
35
+ config_context : Context manager for global configuration.
36
+ set_config : Set global configuration.
37
+ """
38
+ sklearn = skl_get_config()
39
+ sklearnex = onedal_get_config()
40
+ return {**sklearn, **sklearnex}
41
+
42
+
43
+ def set_config(
44
+ target_offload=None,
45
+ allow_fallback_to_host=None,
46
+ allow_sklearn_after_onedal=None,
47
+ **sklearn_configs,
48
+ ):
49
+ """Set global configuration
50
+ Parameters
51
+ ----------
52
+ target_offload : string or dpctl.SyclQueue, default=None
53
+ The device primarily used to perform computations.
54
+ If string, expected to be "auto" (the execution context
55
+ is deduced from input data location),
56
+ or SYCL* filter selector string. Global default: "auto".
57
+ allow_fallback_to_host : bool, default=None
58
+ If True, allows to fallback computation to host device
59
+ in case particular estimator does not support the selected one.
60
+ Global default: False.
61
+ allow_sklearn_after_onedal : bool, default=None
62
+ If True, allows to fallback computation to sklearn after onedal
63
+ backend in case of runtime error on onedal backend computations.
64
+ Global default: True.
65
+ See Also
66
+ --------
67
+ config_context : Context manager for global configuration.
68
+ get_config : Retrieve current values of the global configuration.
69
+ """
70
+
71
+ array_api_dispatch = sklearn_configs.get("array_api_dispatch", False)
72
+ if array_api_dispatch and sklearn_check_version("1.6"):
73
+ environ["SCIPY_ARRAY_API"] = "1"
74
+
75
+ skl_set_config(**sklearn_configs)
76
+
77
+ local_config = onedal_get_config(copy=False)
78
+
79
+ if target_offload is not None:
80
+ local_config["target_offload"] = target_offload
81
+ if allow_fallback_to_host is not None:
82
+ local_config["allow_fallback_to_host"] = allow_fallback_to_host
83
+ if allow_sklearn_after_onedal is not None:
84
+ local_config["allow_sklearn_after_onedal"] = allow_sklearn_after_onedal
85
+
86
+
87
+ @contextmanager
88
+ def config_context(**new_config):
89
+ """Context manager for global scikit-learn configuration
90
+ Parameters
91
+ ----------
92
+ target_offload : string or dpctl.SyclQueue, default=None
93
+ The device primarily used to perform computations.
94
+ If string, expected to be "auto" (the execution context
95
+ is deduced from input data location),
96
+ or SYCL* filter selector string. Global default: "auto".
97
+ allow_fallback_to_host : bool, default=None
98
+ If True, allows to fallback computation to host device
99
+ in case particular estimator does not support the selected one.
100
+ Global default: False.
101
+ Notes
102
+ -----
103
+ All settings, not just those presently modified, will be returned to
104
+ their previous values when the context manager is exited.
105
+ See Also
106
+ --------
107
+ set_config : Set global scikit-learn configuration.
108
+ get_config : Retrieve current values of the global configuration.
109
+ """
110
+ old_config = get_config()
111
+ set_config(**new_config)
112
+
113
+ try:
114
+ yield
115
+ finally:
116
+ set_config(**old_config)