scikit-learn-intelex 2025.10.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.
Files changed (267) hide show
  1. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/__init__.py +73 -0
  2. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/__main__.py +58 -0
  3. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/_daal4py.cp313-win_amd64.pyd +0 -0
  4. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/mb/__init__.py +94 -0
  5. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/mb/gbt_convertors.py +1199 -0
  6. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/mb/logistic_regression_builders.py +211 -0
  7. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/mb/tree_based_builders.py +425 -0
  8. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/mpi_transceiver.cp313-win_amd64.pyd +0 -0
  9. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/__init__.py +40 -0
  10. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/_n_jobs_support.py +252 -0
  11. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/_utils.py +245 -0
  12. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/cluster/__init__.py +20 -0
  13. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/cluster/dbscan.py +165 -0
  14. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/cluster/k_means.py +565 -0
  15. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/cluster/tests/test_dbscan.py +109 -0
  16. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/decomposition/__init__.py +19 -0
  17. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/decomposition/_pca.py +528 -0
  18. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/AdaBoostClassifier.py +192 -0
  19. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/GBTDAAL.py +333 -0
  20. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/__init__.py +27 -0
  21. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/_forest.py +1285 -0
  22. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/tests/test_decision_forest.py +206 -0
  23. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/__init__.py +29 -0
  24. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/_coordinate_descent.py +826 -0
  25. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/_linear.py +269 -0
  26. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/_ridge.py +290 -0
  27. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/coordinate_descent.py +17 -0
  28. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/linear.py +17 -0
  29. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/logistic_loss.py +195 -0
  30. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/logistic_path.py +561 -0
  31. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/ridge.py +17 -0
  32. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/tests/test_enet.py +157 -0
  33. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/tests/test_linear.py +198 -0
  34. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/tests/test_ridge.py +69 -0
  35. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/manifold/__init__.py +19 -0
  36. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/manifold/_t_sne.py +432 -0
  37. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/metrics/__init__.py +20 -0
  38. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/metrics/_pairwise.py +259 -0
  39. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/metrics/_ranking.py +210 -0
  40. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/model_selection/__init__.py +19 -0
  41. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/model_selection/_split.py +309 -0
  42. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/model_selection/tests/test_split.py +56 -0
  43. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/__init__.py +0 -0
  44. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/dispatcher.py +232 -0
  45. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/tests/_models_info.py +164 -0
  46. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/tests/test_monkeypatch.py +71 -0
  47. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/tests/test_patching.py +90 -0
  48. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/tests/utils/_launch_algorithms.py +117 -0
  49. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/__init__.py +21 -0
  50. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/_base.py +493 -0
  51. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/_classification.py +136 -0
  52. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/_regression.py +72 -0
  53. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/_unsupervised.py +55 -0
  54. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/tests/test_kneighbors.py +113 -0
  55. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/svm/__init__.py +19 -0
  56. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/svm/svm.py +736 -0
  57. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/utils/__init__.py +21 -0
  58. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/utils/base.py +80 -0
  59. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/utils/tests/test_utils.py +51 -0
  60. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/utils/validation.py +772 -0
  61. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/__init__.py +151 -0
  62. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/_config.py +80 -0
  63. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/_device_offload.py +199 -0
  64. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/_onedal_py_dpc.cp313-win_amd64.pyd +0 -0
  65. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/_onedal_py_host.cp313-win_amd64.pyd +0 -0
  66. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/basic_statistics/__init__.py +20 -0
  67. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/basic_statistics/basic_statistics.py +151 -0
  68. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/basic_statistics/incremental_basic_statistics.py +165 -0
  69. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/basic_statistics/tests/test_basic_statistics.py +241 -0
  70. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/basic_statistics/tests/test_incremental_basic_statistics.py +279 -0
  71. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/basic_statistics/tests/utils.py +50 -0
  72. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/__init__.py +27 -0
  73. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/dbscan.py +80 -0
  74. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/kmeans.py +582 -0
  75. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/kmeans_init.py +145 -0
  76. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/tests/test_dbscan.py +125 -0
  77. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/tests/test_kmeans.py +88 -0
  78. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/tests/test_kmeans_init.py +93 -0
  79. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/common/_backend.py +258 -0
  80. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/common/_estimator_checks.py +47 -0
  81. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/common/_mixin.py +62 -0
  82. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/common/hyperparameters.py +148 -0
  83. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/common/tests/test_sycl.py +148 -0
  84. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/covariance/__init__.py +20 -0
  85. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/covariance/covariance.py +121 -0
  86. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/covariance/incremental_covariance.py +151 -0
  87. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/covariance/tests/test_covariance.py +50 -0
  88. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/covariance/tests/test_incremental_covariance.py +190 -0
  89. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/datatypes/__init__.py +29 -0
  90. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/datatypes/_data_conversion.py +158 -0
  91. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/datatypes/_dlpack.py +64 -0
  92. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/datatypes/_sycl_usm.py +63 -0
  93. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/datatypes/tests/common.py +131 -0
  94. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/datatypes/tests/test_data.py +686 -0
  95. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/decomposition/__init__.py +20 -0
  96. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/decomposition/incremental_pca.py +218 -0
  97. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/decomposition/pca.py +124 -0
  98. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/decomposition/tests/test_incremental_pca.py +291 -0
  99. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/dummy/__init__.py +19 -0
  100. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/dummy/dummy.py +137 -0
  101. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/ensemble/__init__.py +29 -0
  102. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/ensemble/forest.py +781 -0
  103. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/ensemble/tests/test_random_forest.py +97 -0
  104. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/__init__.py +27 -0
  105. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/incremental_linear_model.py +201 -0
  106. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/linear_model.py +230 -0
  107. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/logistic_regression.py +293 -0
  108. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_incremental_linear_regression.py +213 -0
  109. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_incremental_ridge_regression.py +171 -0
  110. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_linear_regression.py +252 -0
  111. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_logistic_regression.py +95 -0
  112. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_ridge.py +95 -0
  113. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/neighbors/__init__.py +19 -0
  114. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/neighbors/neighbors.py +690 -0
  115. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/neighbors/tests/test_knn_classification.py +49 -0
  116. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/primitives/__init__.py +27 -0
  117. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/primitives/get_tree.py +27 -0
  118. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/primitives/kernel_functions.py +202 -0
  119. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/primitives/tests/test_kernel_functions.py +159 -0
  120. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/__init__.py +19 -0
  121. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/svm.py +592 -0
  122. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/tests/test_csr_svm.py +352 -0
  123. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/tests/test_nusvc.py +204 -0
  124. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/tests/test_nusvr.py +210 -0
  125. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/tests/test_svc.py +168 -0
  126. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/tests/test_svr.py +243 -0
  127. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/tests/test_common.py +71 -0
  128. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/tests/utils/_dataframes_support.py +179 -0
  129. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/tests/utils/_device_selection.py +94 -0
  130. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/utils/_array_api.py +98 -0
  131. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/utils/_sycl_queue_manager.py +213 -0
  132. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/utils/_third_party.py +220 -0
  133. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/utils/tests/test_validation.py +142 -0
  134. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/utils/validation.py +503 -0
  135. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/__init__.py +69 -0
  136. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/__main__.py +58 -0
  137. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/_config.py +163 -0
  138. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/_device_offload.py +205 -0
  139. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/_utils.py +219 -0
  140. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/base.py +109 -0
  141. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/basic_statistics/__init__.py +20 -0
  142. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/basic_statistics/basic_statistics.py +241 -0
  143. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/basic_statistics/incremental_basic_statistics.py +338 -0
  144. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/basic_statistics/tests/test_basic_statistics.py +405 -0
  145. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/basic_statistics/tests/test_incremental_basic_statistics.py +455 -0
  146. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/cluster/__init__.py +20 -0
  147. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/cluster/dbscan.py +199 -0
  148. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/cluster/k_means.py +399 -0
  149. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/cluster/tests/test_dbscan.py +38 -0
  150. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/cluster/tests/test_kmeans.py +157 -0
  151. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/conftest.py +82 -0
  152. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/covariance/__init__.py +19 -0
  153. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/covariance/incremental_covariance.py +440 -0
  154. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/covariance/tests/test_incremental_covariance.py +307 -0
  155. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/decomposition/__init__.py +19 -0
  156. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/decomposition/pca.py +558 -0
  157. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/decomposition/tests/test_pca.py +164 -0
  158. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/dispatcher.py +572 -0
  159. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/doc/third-party-programs.txt +629 -0
  160. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/dummy/__init__.py +19 -0
  161. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/dummy/_dummy.py +615 -0
  162. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/dummy/tests/test_dummy.py +62 -0
  163. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/ensemble/__init__.py +29 -0
  164. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/ensemble/_forest.py +1799 -0
  165. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/ensemble/tests/test_forest.py +196 -0
  166. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/glob/__main__.py +72 -0
  167. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/glob/dispatcher.py +101 -0
  168. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/__init__.py +32 -0
  169. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/coordinate_descent.py +44 -0
  170. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/incremental_linear.py +427 -0
  171. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/incremental_ridge.py +407 -0
  172. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/linear.py +363 -0
  173. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/logistic_regression.py +466 -0
  174. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/ridge.py +407 -0
  175. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_incremental_linear.py +267 -0
  176. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_incremental_ridge.py +214 -0
  177. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_linear.py +167 -0
  178. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_logreg.py +565 -0
  179. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_ridge.py +256 -0
  180. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/manifold/__init__.py +19 -0
  181. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/manifold/t_sne.py +28 -0
  182. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/manifold/tests/test_tsne.py +256 -0
  183. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/metrics/__init__.py +23 -0
  184. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/metrics/pairwise.py +20 -0
  185. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/metrics/ranking.py +20 -0
  186. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/metrics/tests/test_metrics.py +39 -0
  187. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/model_selection/__init__.py +21 -0
  188. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/model_selection/split.py +20 -0
  189. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/model_selection/tests/test_model_selection.py +34 -0
  190. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/__init__.py +27 -0
  191. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/_lof.py +189 -0
  192. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/common.py +313 -0
  193. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/knn_classification.py +189 -0
  194. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/knn_regression.py +167 -0
  195. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/knn_unsupervised.py +170 -0
  196. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/tests/test_neighbors.py +82 -0
  197. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/__init__.py +17 -0
  198. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/covariance/__init__.py +19 -0
  199. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/covariance/covariance.py +261 -0
  200. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/covariance/tests/test_covariance.py +112 -0
  201. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/__init__.py +19 -0
  202. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/incremental_pca.py +406 -0
  203. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/tests/test_incremental_pca.py +390 -0
  204. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/__init__.py +25 -0
  205. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/__init__.py +20 -0
  206. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/basic_statistics.py +24 -0
  207. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/incremental_basic_statistics.py +30 -0
  208. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/tests/test_basic_statistics_spmd.py +117 -0
  209. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/tests/test_incremental_basic_statistics_spmd.py +314 -0
  210. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/__init__.py +30 -0
  211. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/dbscan.py +26 -0
  212. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/kmeans.py +21 -0
  213. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/tests/test_dbscan_spmd.py +108 -0
  214. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/tests/test_kmeans_spmd.py +180 -0
  215. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/__init__.py +20 -0
  216. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/covariance.py +24 -0
  217. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/incremental_covariance.py +29 -0
  218. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/tests/test_covariance_spmd.py +120 -0
  219. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/tests/test_incremental_covariance_spmd.py +200 -0
  220. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/__init__.py +20 -0
  221. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/incremental_pca.py +23 -0
  222. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/pca.py +23 -0
  223. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/tests/test_incremental_pca_spmd.py +276 -0
  224. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/tests/test_pca_spmd.py +146 -0
  225. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/ensemble/__init__.py +19 -0
  226. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/ensemble/forest.py +299 -0
  227. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/ensemble/tests/test_forest_spmd.py +299 -0
  228. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/__init__.py +21 -0
  229. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/incremental_linear_model.py +28 -0
  230. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/linear_model.py +24 -0
  231. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/logistic_regression.py +21 -0
  232. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/tests/test_incremental_linear_spmd.py +345 -0
  233. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/tests/test_linear_regression_spmd.py +162 -0
  234. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/tests/test_logistic_regression_spmd.py +169 -0
  235. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/neighbors/__init__.py +23 -0
  236. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/neighbors/tests/test_neighbors_spmd.py +433 -0
  237. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/__init__.py +29 -0
  238. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/_common.py +403 -0
  239. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/nusvc.py +278 -0
  240. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/nusvr.py +158 -0
  241. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/svc.py +306 -0
  242. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/svr.py +155 -0
  243. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/tests/test_svm.py +124 -0
  244. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_common.py +607 -0
  245. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_config.py +256 -0
  246. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_hyperparameters.py +111 -0
  247. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_memory_usage.py +335 -0
  248. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_monkeypatch.py +269 -0
  249. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_n_jobs_support.py +111 -0
  250. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_parallel.py +48 -0
  251. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_patching.py +418 -0
  252. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability.py +335 -0
  253. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/utils/__init__.py +48 -0
  254. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/utils/base.py +420 -0
  255. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/utils/spmd.py +198 -0
  256. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/__init__.py +19 -0
  257. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/_array_api.py +217 -0
  258. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/class_weight.py +100 -0
  259. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/parallel.py +97 -0
  260. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/tests/test_class_weight.py +69 -0
  261. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/tests/test_validation.py +238 -0
  262. scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/validation.py +212 -0
  263. scikit_learn_intelex-2025.10.0.dist-info/LICENSE.txt +202 -0
  264. scikit_learn_intelex-2025.10.0.dist-info/METADATA +182 -0
  265. scikit_learn_intelex-2025.10.0.dist-info/RECORD +267 -0
  266. scikit_learn_intelex-2025.10.0.dist-info/WHEEL +5 -0
  267. scikit_learn_intelex-2025.10.0.dist-info/top_level.txt +1 -0
@@ -0,0 +1,772 @@
1
+ # ==============================================================================
2
+ # Copyright 2014 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 contextlib import suppress
19
+ from functools import wraps
20
+
21
+ import numpy as np
22
+ import scipy.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 ComplexWarning
27
+ else:
28
+ # numpy_version < 2.0
29
+ from numpy.core.numeric import ComplexWarning
30
+
31
+ from sklearn import get_config as _get_config
32
+ from sklearn.utils.extmath import _safe_accumulator_op
33
+ from sklearn.utils.fixes import _object_dtype_isnan
34
+ from sklearn.utils.validation import _assert_all_finite as _sklearn_assert_all_finite
35
+ from sklearn.utils.validation import (
36
+ _ensure_no_complex_data,
37
+ _ensure_sparse_format,
38
+ _num_samples,
39
+ check_consistent_length,
40
+ column_or_1d,
41
+ )
42
+
43
+ import daal4py as d4p
44
+
45
+ from .._utils import (
46
+ PatchingConditionsChain,
47
+ get_dtype,
48
+ get_number_of_types,
49
+ is_DataFrame,
50
+ sklearn_check_version,
51
+ )
52
+
53
+ if sklearn_check_version("1.6"):
54
+ from sklearn.utils.validation import (
55
+ _check_feature_names as _sklearn_check_feature_names,
56
+ )
57
+ from sklearn.utils.validation import _check_n_features as _sklearn_check_n_features
58
+ from sklearn.utils.validation import validate_data as _sklearn_validate_data
59
+ else:
60
+ from sklearn.base import BaseEstimator
61
+
62
+ _sklearn_validate_data = BaseEstimator._validate_data
63
+ _sklearn_check_feature_names = BaseEstimator._check_feature_names
64
+ _sklearn_check_n_features = BaseEstimator._check_n_features
65
+
66
+
67
+ def _assert_all_finite(
68
+ X, allow_nan=False, msg_dtype=None, estimator_name=None, input_name=""
69
+ ):
70
+ if _get_config()["assume_finite"]:
71
+ return
72
+
73
+ # Data with small size has too big relative overhead
74
+ # TODO: tune threshold size
75
+ is_df = is_DataFrame(X)
76
+ if not (is_df or isinstance(X, np.ndarray)) or X.size < 32768:
77
+ if sklearn_check_version("1.1"):
78
+ _sklearn_assert_all_finite(
79
+ X,
80
+ allow_nan=allow_nan,
81
+ msg_dtype=msg_dtype,
82
+ estimator_name=estimator_name,
83
+ input_name=input_name,
84
+ )
85
+ else:
86
+ _sklearn_assert_all_finite(X, allow_nan=allow_nan, msg_dtype=msg_dtype)
87
+ return
88
+
89
+ num_of_types = get_number_of_types(X)
90
+
91
+ # if X is heterogeneous pandas.DataFrame then
92
+ # convert it to a list of arrays
93
+ if is_df and num_of_types > 1:
94
+ lst = []
95
+ for idx in X:
96
+ arr = X[idx].to_numpy()
97
+ lst.append(arr if arr.flags["C_CONTIGUOUS"] else np.ascontiguousarray(arr))
98
+ else:
99
+ X = np.asanyarray(X)
100
+ is_df = False
101
+
102
+ dt = np.dtype(get_dtype(X))
103
+ is_float = dt.kind in "fc"
104
+
105
+ msg_err = "Input {} contains {} or a value too large for {!r}."
106
+ type_err = "infinity" if allow_nan else "NaN, infinity"
107
+ err = msg_err.format(input_name, type_err, msg_dtype if msg_dtype is not None else dt)
108
+
109
+ _patching_status = PatchingConditionsChain(
110
+ "sklearn.utils.validation._assert_all_finite"
111
+ )
112
+ _dal_ready = _patching_status.and_conditions(
113
+ [
114
+ (X.ndim in [1, 2], f"Input {input_name} does not have 1 or 2 dimensions."),
115
+ (not np.any(np.equal(X.shape, 0)), f"Input {input_name} shape contains a 0."),
116
+ (
117
+ dt in [np.float32, np.float64],
118
+ f"Input {input_name} dtype is not float32 or float64.",
119
+ ),
120
+ ]
121
+ )
122
+ _patching_status.write_log()
123
+ if _dal_ready:
124
+ if X.ndim == 1:
125
+ X = X.reshape((-1, 1))
126
+
127
+ x_for_daal = lst if is_df and num_of_types > 1 else X
128
+
129
+ if dt == np.float64:
130
+ if not d4p.daal_assert_all_finite(x_for_daal, allow_nan, 0):
131
+ raise ValueError(err)
132
+ elif dt == np.float32:
133
+ if not d4p.daal_assert_all_finite(x_for_daal, allow_nan, 1):
134
+ raise ValueError(err)
135
+ # First try an O(n) time, O(1) space solution for the common case that
136
+ # everything is finite; fall back to O(n) space np.isfinite to prevent
137
+ # false positives from overflow in sum method. The sum is also calculated
138
+ # safely to reduce dtype induced overflows.
139
+ elif is_float and (np.isfinite(_safe_accumulator_op(np.sum, X))):
140
+ pass
141
+ elif is_float:
142
+ if allow_nan and np.isinf(X).any() or not allow_nan and not np.isfinite(X).all():
143
+ raise ValueError(err)
144
+ # for object dtype data, we only check for NaNs (GH-13254)
145
+ elif dt == np.dtype("object") and not allow_nan:
146
+ if _object_dtype_isnan(X).any():
147
+ raise ValueError(f"Input {input_name} contains NaN")
148
+
149
+
150
+ def _pandas_check_array(
151
+ array,
152
+ array_orig,
153
+ force_all_finite,
154
+ ensure_min_samples,
155
+ ensure_min_features,
156
+ copy,
157
+ context,
158
+ ):
159
+ if force_all_finite:
160
+ _assert_all_finite(array, allow_nan=force_all_finite == "allow-nan")
161
+
162
+ if ensure_min_samples > 0:
163
+ n_samples = _num_samples(array)
164
+ if n_samples < ensure_min_samples:
165
+ raise ValueError(
166
+ "Found array with %d sample(s) (shape=%s) while a"
167
+ " minimum of %d is required%s."
168
+ % (n_samples, array.shape, ensure_min_samples, context)
169
+ )
170
+
171
+ if ensure_min_features > 0:
172
+ n_features = array.shape[1]
173
+ if n_features < ensure_min_features:
174
+ raise ValueError(
175
+ "Found array with %d feature(s) (shape=%s) while"
176
+ " a minimum of %d is required%s."
177
+ % (n_features, array.shape, ensure_min_features, context)
178
+ )
179
+
180
+ if copy and np.may_share_memory(array, array_orig):
181
+ array = array.copy()
182
+
183
+ return array
184
+
185
+
186
+ def _daal_check_array(
187
+ array,
188
+ accept_sparse=False,
189
+ *,
190
+ accept_large_sparse=True,
191
+ dtype="numeric",
192
+ order=None,
193
+ copy=False,
194
+ force_all_finite=True,
195
+ ensure_2d=True,
196
+ allow_nd=False,
197
+ ensure_min_samples=1,
198
+ ensure_min_features=1,
199
+ estimator=None,
200
+ ):
201
+ """Input validation on an array, list, sparse matrix or similar.
202
+
203
+ By default, the input is checked to be a non-empty 2D array containing
204
+ only finite values. If the dtype of the array is object, attempt
205
+ converting to float, raising on failure.
206
+
207
+ Parameters
208
+ ----------
209
+ array : object
210
+ Input object to check / convert.
211
+
212
+ accept_sparse : string, boolean or list/tuple of strings (default=False)
213
+ String[s] representing allowed sparse matrix formats, such as 'csc',
214
+ 'csr', etc. If the input is sparse but not in the allowed format,
215
+ it will be converted to the first listed format. True allows the input
216
+ to be any format. False means that a sparse matrix input will
217
+ raise an error.
218
+
219
+ accept_large_sparse : bool (default=True)
220
+ If a CSR, CSC, COO or BSR sparse matrix is supplied and accepted by
221
+ accept_sparse, accept_large_sparse=False will cause it to be accepted
222
+ only if its indices are stored with a 32-bit dtype.
223
+
224
+ .. versionadded:: 0.20
225
+
226
+ dtype : string, type, list of types or None (default="numeric")
227
+ Data type of result. If None, the dtype of the input is preserved.
228
+ If "numeric", dtype is preserved unless array.dtype is object.
229
+ If dtype is a list of types, conversion on the first type is only
230
+ performed if the dtype of the input is not in the list.
231
+
232
+ order : 'F', 'C' or None (default=None)
233
+ Whether an array will be forced to be fortran or c-style.
234
+ When order is None (default), then if copy=False, nothing is ensured
235
+ about the memory layout of the output array; otherwise (copy=True)
236
+ the memory layout of the returned array is kept as close as possible
237
+ to the original array.
238
+
239
+ copy : boolean (default=False)
240
+ Whether a forced copy will be triggered. If copy=False, a copy might
241
+ be triggered by a conversion.
242
+
243
+ force_all_finite : boolean or 'allow-nan', (default=True)
244
+ Whether to raise an error on np.inf, np.nan, pd.NA in array. The
245
+ possibilities are:
246
+
247
+ - True: Force all values of array to be finite.
248
+ - False: accepts np.inf, np.nan, pd.NA in array.
249
+ - 'allow-nan': accepts only np.nan and pd.NA values in array. Values
250
+ cannot be infinite.
251
+
252
+ .. versionadded:: 0.20
253
+ ``force_all_finite`` accepts the string ``'allow-nan'``.
254
+
255
+ .. versionchanged:: 0.23
256
+ Accepts `pd.NA` and converts it into `np.nan`
257
+
258
+ ensure_2d : boolean (default=True)
259
+ Whether to raise a value error if array is not 2D.
260
+
261
+ allow_nd : boolean (default=False)
262
+ Whether to allow array.ndim > 2.
263
+
264
+ ensure_min_samples : int (default=1)
265
+ Make sure that the array has a minimum number of samples in its first
266
+ axis (rows for a 2D array). Setting to 0 disables this check.
267
+
268
+ ensure_min_features : int (default=1)
269
+ Make sure that the 2D array has some minimum number of features
270
+ (columns). The default value of 1 rejects empty datasets.
271
+ This check is only enforced when the input data has effectively 2
272
+ dimensions or is originally 1D and ``ensure_2d`` is True. Setting to 0
273
+ disables this check.
274
+
275
+ estimator : str or estimator instance (default=None)
276
+ If passed, include the name of the estimator in warning messages.
277
+
278
+ Returns
279
+ -------
280
+ array_converted : object
281
+ The converted and validated array.
282
+ """
283
+ if force_all_finite not in (True, False, "allow-nan", None):
284
+ raise ValueError(
285
+ 'force_all_finite should be a bool, None, or "allow-nan"'
286
+ ". Got {!r} instead".format(force_all_finite)
287
+ )
288
+
289
+ if estimator is not None:
290
+ if isinstance(estimator, str):
291
+ estimator_name = estimator
292
+ else:
293
+ estimator_name = estimator.__class__.__name__
294
+ else:
295
+ estimator_name = "Estimator"
296
+ context = " by %s" % estimator_name if estimator is not None else ""
297
+
298
+ array_orig = array
299
+
300
+ # a branch for heterogeneous pandas.DataFrame
301
+ if is_DataFrame(array) and get_number_of_types(array) > 1:
302
+ from pandas import SparseDtype
303
+
304
+ def is_sparse(dtype):
305
+ return isinstance(dtype, SparseDtype)
306
+
307
+ if hasattr(array, "sparse") or not array.dtypes.apply(is_sparse).any():
308
+ return _pandas_check_array(
309
+ array,
310
+ array_orig,
311
+ force_all_finite,
312
+ ensure_min_samples,
313
+ ensure_min_features,
314
+ copy,
315
+ context,
316
+ )
317
+
318
+ # store whether originally we wanted numeric dtype
319
+ dtype_numeric = isinstance(dtype, str) and dtype == "numeric"
320
+
321
+ dtype_orig = getattr(array, "dtype", None)
322
+ if not hasattr(dtype_orig, "kind"):
323
+ # not a data type (e.g. a column named dtype in a pandas DataFrame)
324
+ dtype_orig = None
325
+
326
+ # check if the object contains several dtypes (typically a pandas
327
+ # DataFrame), and store them. If not, store None.
328
+ dtypes_orig = None
329
+ has_pd_integer_array = False
330
+ if hasattr(array, "dtypes") and hasattr(array.dtypes, "__array__"):
331
+ # throw warning if columns are sparse. If all columns are sparse, then
332
+ # array.sparse exists and sparsity will be preserved (later).
333
+ with suppress(ImportError):
334
+ from pandas import SparseDtype
335
+
336
+ def is_sparse(dtype):
337
+ return isinstance(dtype, SparseDtype)
338
+
339
+ if not hasattr(array, "sparse") and array.dtypes.apply(is_sparse).any():
340
+ warnings.warn(
341
+ "pandas.DataFrame with sparse columns found."
342
+ "It will be converted to a dense numpy array."
343
+ )
344
+
345
+ dtypes_orig = list(array.dtypes)
346
+ # pandas boolean dtype __array__ interface coerces bools to objects
347
+ for i, dtype_iter in enumerate(dtypes_orig):
348
+ if dtype_iter.kind == "b":
349
+ dtypes_orig[i] = np.dtype(np.object)
350
+ elif dtype_iter.name.startswith(("Int", "UInt")):
351
+ # name looks like an Integer Extension Array, now check for
352
+ # the dtype
353
+ with suppress(ImportError):
354
+ from pandas import (
355
+ Int8Dtype,
356
+ Int16Dtype,
357
+ Int32Dtype,
358
+ Int64Dtype,
359
+ UInt8Dtype,
360
+ UInt16Dtype,
361
+ UInt32Dtype,
362
+ UInt64Dtype,
363
+ )
364
+
365
+ if isinstance(
366
+ dtype_iter,
367
+ (
368
+ Int8Dtype,
369
+ Int16Dtype,
370
+ Int32Dtype,
371
+ Int64Dtype,
372
+ UInt8Dtype,
373
+ UInt16Dtype,
374
+ UInt32Dtype,
375
+ UInt64Dtype,
376
+ ),
377
+ ):
378
+ has_pd_integer_array = True
379
+
380
+ if all(isinstance(dtype, np.dtype) for dtype in dtypes_orig):
381
+ dtype_orig = np.result_type(*dtypes_orig)
382
+
383
+ if dtype_numeric:
384
+ if dtype_orig is not None and dtype_orig.kind == "O":
385
+ # if input is object, convert to float.
386
+ dtype = np.float64
387
+ else:
388
+ dtype = None
389
+
390
+ if isinstance(dtype, (list, tuple)):
391
+ if dtype_orig is not None and dtype_orig in dtype:
392
+ # no dtype conversion required
393
+ dtype = None
394
+ else:
395
+ # dtype conversion required. Let's select the first element of the
396
+ # list of accepted types.
397
+ dtype = dtype[0]
398
+
399
+ if has_pd_integer_array:
400
+ # If there are any pandas integer extension arrays,
401
+ array = array.astype(dtype)
402
+
403
+ # When all dataframe columns are sparse, convert to a sparse array
404
+ if hasattr(array, "sparse") and array.ndim > 1:
405
+ # DataFrame.sparse only supports `to_coo`
406
+ array = array.sparse.to_coo()
407
+
408
+ if sp.issparse(array):
409
+ _ensure_no_complex_data(array)
410
+ kwargs = {
411
+ "accept_sparse": accept_sparse,
412
+ "dtype": dtype,
413
+ "copy": copy,
414
+ "accept_large_sparse": accept_large_sparse,
415
+ }
416
+ if sklearn_check_version("1.6"):
417
+ kwargs["ensure_all_finite"] = force_all_finite
418
+ else:
419
+ kwargs["force_all_finite"] = force_all_finite
420
+ array = _ensure_sparse_format(
421
+ array,
422
+ **kwargs,
423
+ )
424
+ else:
425
+ # If np.array(..) gives ComplexWarning, then we convert the warning
426
+ # to an error. This is needed because specifying a non complex
427
+ # dtype to the function converts complex to real dtype,
428
+ # thereby passing the test made in the lines following the scope
429
+ # of warnings context manager.
430
+ with warnings.catch_warnings():
431
+ try:
432
+ warnings.simplefilter("error", ComplexWarning)
433
+ if dtype is not None and np.dtype(dtype).kind in "iu":
434
+ # Conversion float -> int should not contain NaN or
435
+ # inf (numpy#14412). We cannot use casting='safe' because
436
+ # then conversion float -> int would be disallowed.
437
+ array = np.asarray(array, order=order)
438
+ if array.dtype.kind == "f":
439
+ _assert_all_finite(array, allow_nan=False, msg_dtype=dtype)
440
+ array = array.astype(dtype, casting="unsafe", copy=False)
441
+ else:
442
+ array = np.asarray(array, order=order, dtype=dtype)
443
+ except ComplexWarning:
444
+ raise ValueError("Complex data not supported\n" "{}\n".format(array))
445
+
446
+ # It is possible that the np.array(..) gave no warning. This happens
447
+ # when no dtype conversion happened, for example dtype = None. The
448
+ # result is that np.array(..) produces an array of complex dtype
449
+ # and we need to catch and raise exception for such cases.
450
+ _ensure_no_complex_data(array) # doing nothing for DataFrame
451
+
452
+ if ensure_2d:
453
+ # If input is scalar raise error
454
+ if array.ndim == 0:
455
+ raise ValueError(
456
+ "Expected 2D array, got scalar array instead:\narray={}.\n"
457
+ "Reshape your data either using array.reshape(-1, 1) if "
458
+ "your data has a single feature or array.reshape(1, -1) "
459
+ "if it contains a single sample.".format(array)
460
+ )
461
+ # If input is 1D raise error
462
+ if array.ndim == 1:
463
+ raise ValueError(
464
+ "Expected 2D array, got 1D array instead:\narray={}.\n"
465
+ "Reshape your data either using array.reshape(-1, 1) if "
466
+ "your data has a single feature or array.reshape(1, -1) "
467
+ "if it contains a single sample.".format(array)
468
+ )
469
+
470
+ # in the future np.flexible dtypes will be handled like object dtypes
471
+ if dtype_numeric and np.issubdtype(array.dtype, np.flexible):
472
+ warnings.warn(
473
+ "Beginning in version 0.22, arrays of bytes/strings will be "
474
+ "converted to decimal numbers if dtype='numeric'. "
475
+ "It is recommended that you convert the array to "
476
+ "a float dtype before using it in scikit-learn, "
477
+ "for example by using "
478
+ "your_array = your_array.astype(np.float64).",
479
+ FutureWarning,
480
+ stacklevel=2,
481
+ )
482
+
483
+ # make sure we actually converted to numeric:
484
+ if dtype_numeric and array.dtype.kind == "O":
485
+ array = array.astype(np.float64)
486
+ if not allow_nd and array.ndim >= 3:
487
+ raise ValueError(
488
+ "Found array with dim %d. %s expected <= 2."
489
+ % (array.ndim, estimator_name)
490
+ )
491
+
492
+ if force_all_finite:
493
+ _assert_all_finite(array, allow_nan=force_all_finite == "allow-nan")
494
+
495
+ if ensure_min_samples > 0:
496
+ n_samples = _num_samples(array)
497
+ if n_samples < ensure_min_samples:
498
+ raise ValueError(
499
+ "Found array with %d sample(s) (shape=%s) while a"
500
+ " minimum of %d is required%s."
501
+ % (n_samples, array.shape, ensure_min_samples, context)
502
+ )
503
+
504
+ if ensure_min_features > 0 and array.ndim == 2:
505
+ n_features = array.shape[1]
506
+ if n_features < ensure_min_features:
507
+ raise ValueError(
508
+ "Found array with %d feature(s) (shape=%s) while"
509
+ " a minimum of %d is required%s."
510
+ % (n_features, array.shape, ensure_min_features, context)
511
+ )
512
+
513
+ if copy and np.may_share_memory(array, array_orig):
514
+ array = np.array(array, dtype=dtype, order=order)
515
+
516
+ return array
517
+
518
+
519
+ def _daal_check_X_y(
520
+ X,
521
+ y,
522
+ accept_sparse=False,
523
+ *,
524
+ accept_large_sparse=True,
525
+ dtype="numeric",
526
+ order=None,
527
+ copy=False,
528
+ force_all_finite=True,
529
+ ensure_2d=True,
530
+ allow_nd=False,
531
+ multi_output=False,
532
+ ensure_min_samples=1,
533
+ ensure_min_features=1,
534
+ y_numeric=False,
535
+ estimator=None,
536
+ ):
537
+ """Input validation for standard estimators.
538
+
539
+ Checks X and y for consistent length, enforces X to be 2D and y 1D. By
540
+ default, X is checked to be non-empty and containing only finite values.
541
+ Standard input checks are also applied to y, such as checking that y
542
+ does not have np.nan or np.inf targets. For multi-label y, set
543
+ multi_output=True to allow 2D and sparse y. If the dtype of X is
544
+ object, attempt converting to float, raising on failure.
545
+
546
+ Parameters
547
+ ----------
548
+ X : nd-array, list or sparse matrix
549
+ Input data.
550
+
551
+ y : nd-array, list or sparse matrix
552
+ Labels.
553
+
554
+ accept_sparse : string, boolean or list of string (default=False)
555
+ String[s] representing allowed sparse matrix formats, such as 'csc',
556
+ 'csr', etc. If the input is sparse but not in the allowed format,
557
+ it will be converted to the first listed format. True allows the input
558
+ to be any format. False means that a sparse matrix input will
559
+ raise an error.
560
+
561
+ accept_large_sparse : bool (default=True)
562
+ If a CSR, CSC, COO or BSR sparse matrix is supplied and accepted by
563
+ accept_sparse, accept_large_sparse will cause it to be accepted only
564
+ if its indices are stored with a 32-bit dtype.
565
+
566
+ .. versionadded:: 0.20
567
+
568
+ dtype : string, type, list of types or None (default="numeric")
569
+ Data type of result. If None, the dtype of the input is preserved.
570
+ If "numeric", dtype is preserved unless array.dtype is object.
571
+ If dtype is a list of types, conversion on the first type is only
572
+ performed if the dtype of the input is not in the list.
573
+
574
+ order : 'F', 'C' or None (default=None)
575
+ Whether an array will be forced to be fortran or c-style.
576
+
577
+ copy : boolean (default=False)
578
+ Whether a forced copy will be triggered. If copy=False, a copy might
579
+ be triggered by a conversion.
580
+
581
+ force_all_finite : boolean or 'allow-nan', (default=True)
582
+ Whether to raise an error on np.inf, np.nan, pd.NA in X. This parameter
583
+ does not influence whether y can have np.inf, np.nan, pd.NA values.
584
+ The possibilities are:
585
+
586
+ - True: Force all values of X to be finite.
587
+ - False: accepts np.inf, np.nan, pd.NA in X.
588
+ - 'allow-nan': accepts only np.nan or pd.NA values in X. Values cannot
589
+ be infinite.
590
+
591
+ .. versionadded:: 0.20
592
+ ``force_all_finite`` accepts the string ``'allow-nan'``.
593
+
594
+ .. versionchanged:: 0.23
595
+ Accepts `pd.NA` and converts it into `np.nan`
596
+
597
+ ensure_2d : boolean (default=True)
598
+ Whether to raise a value error if X is not 2D.
599
+
600
+ allow_nd : boolean (default=False)
601
+ Whether to allow X.ndim > 2.
602
+
603
+ multi_output : boolean (default=False)
604
+ Whether to allow 2D y (array or sparse matrix). If false, y will be
605
+ validated as a vector. y cannot have np.nan or np.inf values if
606
+ multi_output=True.
607
+
608
+ ensure_min_samples : int (default=1)
609
+ Make sure that X has a minimum number of samples in its first
610
+ axis (rows for a 2D array).
611
+
612
+ ensure_min_features : int (default=1)
613
+ Make sure that the 2D array has some minimum number of features
614
+ (columns). The default value of 1 rejects empty datasets.
615
+ This check is only enforced when X has effectively 2 dimensions or
616
+ is originally 1D and ``ensure_2d`` is True. Setting to 0 disables
617
+ this check.
618
+
619
+ y_numeric : boolean (default=False)
620
+ Whether to ensure that y has a numeric type. If dtype of y is object,
621
+ it is converted to float64. Should only be used for regression
622
+ algorithms.
623
+
624
+ estimator : str or estimator instance (default=None)
625
+ If passed, include the name of the estimator in warning messages.
626
+
627
+ Returns
628
+ -------
629
+ X_converted : object
630
+ The converted and validated X.
631
+
632
+ y_converted : object
633
+ The converted and validated y.
634
+ """
635
+ if y is None:
636
+ raise ValueError("y cannot be None")
637
+
638
+ X = _daal_check_array(
639
+ X,
640
+ accept_sparse=accept_sparse,
641
+ accept_large_sparse=accept_large_sparse,
642
+ dtype=dtype,
643
+ order=order,
644
+ copy=copy,
645
+ force_all_finite=force_all_finite,
646
+ ensure_2d=ensure_2d,
647
+ allow_nd=allow_nd,
648
+ ensure_min_samples=ensure_min_samples,
649
+ ensure_min_features=ensure_min_features,
650
+ estimator=estimator,
651
+ )
652
+ if multi_output:
653
+ y = _daal_check_array(
654
+ y, accept_sparse="csr", force_all_finite=True, ensure_2d=False, dtype=None
655
+ )
656
+ else:
657
+ y = column_or_1d(y, warn=True)
658
+ _assert_all_finite(y)
659
+ if y_numeric and hasattr(y, "dtype") and y.dtype.kind == "O":
660
+ y = y.astype(np.float64)
661
+
662
+ check_consistent_length(X, y)
663
+
664
+ return X, y
665
+
666
+
667
+ def _daal_num_features(X):
668
+ """Return the number of features in an array-like X.
669
+ This helper function tries hard to avoid to materialize an array version
670
+ of X unless necessary. For instance, if X is a list of lists,
671
+ this function will return the length of the first element, assuming
672
+ that subsequent elements are all lists of the same length without
673
+ checking.
674
+ Parameters
675
+ ----------
676
+ X : array-like
677
+ array-like to get the number of features.
678
+ Returns
679
+ -------
680
+ features : int
681
+ Number of features
682
+ """
683
+ type_ = type(X)
684
+ if type_.__module__ == "builtins":
685
+ type_name = type_.__qualname__
686
+ else:
687
+ type_name = f"{type_.__module__}.{type_.__qualname__}"
688
+ message = f"Unable to find the number of features from X of type {type_name}"
689
+ if not hasattr(X, "__len__") and not hasattr(X, "shape"):
690
+ if not hasattr(X, "__array__"):
691
+ raise TypeError(message)
692
+ # Only convert X to a numpy array if there is no cheaper, heuristic
693
+ # option.
694
+ X = np.asarray(X)
695
+
696
+ if hasattr(X, "shape"):
697
+ if not hasattr(X.shape, "__len__") or len(X.shape) <= 1:
698
+ message += f" with shape {X.shape}"
699
+ raise TypeError(message)
700
+ return X.shape[1]
701
+
702
+ first_sample = X[0]
703
+
704
+ # Do not consider an array-like of strings or dicts to be a 2D array
705
+ if isinstance(first_sample, (str, bytes, dict)):
706
+ message += f" where the samples are of type {type(first_sample).__qualname__}"
707
+ raise TypeError(message)
708
+
709
+ try:
710
+ # If X is a list of lists, for instance, we assume that all nested
711
+ # lists have the same length without checking or converting to
712
+ # a numpy array to keep this function call as cheap as possible.
713
+ return len(first_sample)
714
+ except Exception as err:
715
+ raise TypeError(message) from err
716
+
717
+
718
+ def get_requires_y_tag(estimator):
719
+ """Gets the value of the 'requires_y' tag from the estimator
720
+ using correct code path depending on the scikit-learn version."""
721
+ if sklearn_check_version("1.6"):
722
+ requires_y = estimator.__sklearn_tags__().target_tags.required
723
+ else:
724
+ try:
725
+ requires_y = estimator._get_tags()["requires_y"]
726
+ except KeyError:
727
+ requires_y = False
728
+ return requires_y
729
+
730
+
731
+ def add_dispatcher_docstring(original_function):
732
+ """Adds a note about the dispatcher function to the docstring of the original function."""
733
+
734
+ def wrapper(dispatcher_function):
735
+ @wraps(
736
+ original_function,
737
+ ["__name__", "__doc__", "__annotations__", "__type_params__"],
738
+ )
739
+ def new_function(*args, **kwargs):
740
+ return dispatcher_function(*args, **kwargs)
741
+
742
+ new_function.__doc__ = (
743
+ f"Sklearnex dispatcher for '{original_function.__qualname__}' "
744
+ f"from '{original_function.__module__}' module supporting "
745
+ "it's multiple implementations from different scikit-learn versions.\n\n"
746
+ + original_function.__doc__
747
+ )
748
+
749
+ return new_function
750
+
751
+ return wrapper
752
+
753
+
754
+ # simplified copy of similar function from sklearnex.utils.validation,
755
+ # ensures that the correct finiteness check argument is used
756
+ @add_dispatcher_docstring(_sklearn_validate_data)
757
+ def validate_data(*args, **kwargs):
758
+ if not sklearn_check_version("1.6") and "ensure_all_finite" in kwargs:
759
+ kwargs["force_all_finite"] = kwargs.pop("ensure_all_finite")
760
+ return _sklearn_validate_data(*args, **kwargs)
761
+
762
+
763
+ # dispatcher functions which use correct `check_feature_names`/`check_n_features` import
764
+ # depending on the scikit-learn version
765
+ @add_dispatcher_docstring(_sklearn_check_feature_names)
766
+ def check_feature_names(*args, **kwargs):
767
+ _sklearn_check_feature_names(*args, **kwargs)
768
+
769
+
770
+ @add_dispatcher_docstring(_sklearn_check_n_features)
771
+ def check_n_features(*args, **kwargs):
772
+ _sklearn_check_n_features(*args, **kwargs)