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.
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/__init__.py +73 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/__main__.py +58 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/_daal4py.cp313-win_amd64.pyd +0 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/mb/__init__.py +94 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/mb/gbt_convertors.py +1199 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/mb/logistic_regression_builders.py +211 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/mb/tree_based_builders.py +425 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/mpi_transceiver.cp313-win_amd64.pyd +0 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/__init__.py +40 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/_n_jobs_support.py +252 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/_utils.py +245 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/cluster/__init__.py +20 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/cluster/dbscan.py +165 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/cluster/k_means.py +565 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/cluster/tests/test_dbscan.py +109 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/decomposition/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/decomposition/_pca.py +528 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/AdaBoostClassifier.py +192 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/GBTDAAL.py +333 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/__init__.py +27 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/_forest.py +1285 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/ensemble/tests/test_decision_forest.py +206 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/__init__.py +29 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/_coordinate_descent.py +826 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/_linear.py +269 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/_ridge.py +290 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/coordinate_descent.py +17 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/linear.py +17 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/logistic_loss.py +195 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/logistic_path.py +561 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/ridge.py +17 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/tests/test_enet.py +157 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/tests/test_linear.py +198 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/linear_model/tests/test_ridge.py +69 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/manifold/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/manifold/_t_sne.py +432 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/metrics/__init__.py +20 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/metrics/_pairwise.py +259 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/metrics/_ranking.py +210 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/model_selection/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/model_selection/_split.py +309 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/model_selection/tests/test_split.py +56 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/__init__.py +0 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/dispatcher.py +232 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/tests/_models_info.py +164 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/tests/test_monkeypatch.py +71 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/tests/test_patching.py +90 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/monkeypatch/tests/utils/_launch_algorithms.py +117 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/__init__.py +21 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/_base.py +493 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/_classification.py +136 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/_regression.py +72 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/_unsupervised.py +55 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/neighbors/tests/test_kneighbors.py +113 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/svm/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/svm/svm.py +736 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/utils/__init__.py +21 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/utils/base.py +80 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/utils/tests/test_utils.py +51 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/daal4py/sklearn/utils/validation.py +772 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/__init__.py +151 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/_config.py +80 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/_device_offload.py +199 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/_onedal_py_dpc.cp313-win_amd64.pyd +0 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/_onedal_py_host.cp313-win_amd64.pyd +0 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/basic_statistics/__init__.py +20 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/basic_statistics/basic_statistics.py +151 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/basic_statistics/incremental_basic_statistics.py +165 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/basic_statistics/tests/test_basic_statistics.py +241 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/basic_statistics/tests/test_incremental_basic_statistics.py +279 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/basic_statistics/tests/utils.py +50 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/__init__.py +27 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/dbscan.py +80 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/kmeans.py +582 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/kmeans_init.py +145 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/tests/test_dbscan.py +125 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/tests/test_kmeans.py +88 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/cluster/tests/test_kmeans_init.py +93 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/common/_backend.py +258 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/common/_estimator_checks.py +47 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/common/_mixin.py +62 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/common/hyperparameters.py +148 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/common/tests/test_sycl.py +148 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/covariance/__init__.py +20 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/covariance/covariance.py +121 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/covariance/incremental_covariance.py +151 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/covariance/tests/test_covariance.py +50 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/covariance/tests/test_incremental_covariance.py +190 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/datatypes/__init__.py +29 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/datatypes/_data_conversion.py +158 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/datatypes/_dlpack.py +64 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/datatypes/_sycl_usm.py +63 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/datatypes/tests/common.py +131 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/datatypes/tests/test_data.py +686 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/decomposition/__init__.py +20 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/decomposition/incremental_pca.py +218 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/decomposition/pca.py +124 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/decomposition/tests/test_incremental_pca.py +291 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/dummy/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/dummy/dummy.py +137 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/ensemble/__init__.py +29 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/ensemble/forest.py +781 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/ensemble/tests/test_random_forest.py +97 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/__init__.py +27 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/incremental_linear_model.py +201 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/linear_model.py +230 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/logistic_regression.py +293 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_incremental_linear_regression.py +213 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_incremental_ridge_regression.py +171 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_linear_regression.py +252 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_logistic_regression.py +95 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/linear_model/tests/test_ridge.py +95 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/neighbors/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/neighbors/neighbors.py +690 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/neighbors/tests/test_knn_classification.py +49 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/primitives/__init__.py +27 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/primitives/get_tree.py +27 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/primitives/kernel_functions.py +202 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/primitives/tests/test_kernel_functions.py +159 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/svm.py +592 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/tests/test_csr_svm.py +352 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/tests/test_nusvc.py +204 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/tests/test_nusvr.py +210 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/tests/test_svc.py +168 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/svm/tests/test_svr.py +243 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/tests/test_common.py +71 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/tests/utils/_dataframes_support.py +179 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/tests/utils/_device_selection.py +94 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/utils/_array_api.py +98 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/utils/_sycl_queue_manager.py +213 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/utils/_third_party.py +220 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/utils/tests/test_validation.py +142 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/onedal/utils/validation.py +503 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/__init__.py +69 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/__main__.py +58 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/_config.py +163 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/_device_offload.py +205 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/_utils.py +219 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/base.py +109 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/basic_statistics/__init__.py +20 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/basic_statistics/basic_statistics.py +241 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/basic_statistics/incremental_basic_statistics.py +338 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/basic_statistics/tests/test_basic_statistics.py +405 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/basic_statistics/tests/test_incremental_basic_statistics.py +455 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/cluster/__init__.py +20 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/cluster/dbscan.py +199 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/cluster/k_means.py +399 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/cluster/tests/test_dbscan.py +38 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/cluster/tests/test_kmeans.py +157 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/conftest.py +82 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/covariance/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/covariance/incremental_covariance.py +440 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/covariance/tests/test_incremental_covariance.py +307 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/decomposition/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/decomposition/pca.py +558 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/decomposition/tests/test_pca.py +164 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/dispatcher.py +572 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/doc/third-party-programs.txt +629 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/dummy/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/dummy/_dummy.py +615 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/dummy/tests/test_dummy.py +62 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/ensemble/__init__.py +29 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/ensemble/_forest.py +1799 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/ensemble/tests/test_forest.py +196 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/glob/__main__.py +72 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/glob/dispatcher.py +101 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/__init__.py +32 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/coordinate_descent.py +44 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/incremental_linear.py +427 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/incremental_ridge.py +407 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/linear.py +363 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/logistic_regression.py +466 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/ridge.py +407 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_incremental_linear.py +267 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_incremental_ridge.py +214 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_linear.py +167 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_logreg.py +565 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_ridge.py +256 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/manifold/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/manifold/t_sne.py +28 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/manifold/tests/test_tsne.py +256 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/metrics/__init__.py +23 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/metrics/pairwise.py +20 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/metrics/ranking.py +20 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/metrics/tests/test_metrics.py +39 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/model_selection/__init__.py +21 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/model_selection/split.py +20 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/model_selection/tests/test_model_selection.py +34 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/__init__.py +27 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/_lof.py +189 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/common.py +313 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/knn_classification.py +189 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/knn_regression.py +167 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/knn_unsupervised.py +170 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/neighbors/tests/test_neighbors.py +82 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/__init__.py +17 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/covariance/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/covariance/covariance.py +261 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/covariance/tests/test_covariance.py +112 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/incremental_pca.py +406 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/tests/test_incremental_pca.py +390 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/__init__.py +25 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/__init__.py +20 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/basic_statistics.py +24 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/incremental_basic_statistics.py +30 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/tests/test_basic_statistics_spmd.py +117 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/tests/test_incremental_basic_statistics_spmd.py +314 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/__init__.py +30 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/dbscan.py +26 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/kmeans.py +21 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/tests/test_dbscan_spmd.py +108 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/tests/test_kmeans_spmd.py +180 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/__init__.py +20 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/covariance.py +24 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/incremental_covariance.py +29 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/tests/test_covariance_spmd.py +120 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/tests/test_incremental_covariance_spmd.py +200 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/__init__.py +20 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/incremental_pca.py +23 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/pca.py +23 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/tests/test_incremental_pca_spmd.py +276 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/tests/test_pca_spmd.py +146 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/ensemble/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/ensemble/forest.py +299 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/ensemble/tests/test_forest_spmd.py +299 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/__init__.py +21 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/incremental_linear_model.py +28 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/linear_model.py +24 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/logistic_regression.py +21 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/tests/test_incremental_linear_spmd.py +345 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/tests/test_linear_regression_spmd.py +162 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/tests/test_logistic_regression_spmd.py +169 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/neighbors/__init__.py +23 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/spmd/neighbors/tests/test_neighbors_spmd.py +433 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/__init__.py +29 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/_common.py +403 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/nusvc.py +278 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/nusvr.py +158 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/svc.py +306 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/svr.py +155 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/svm/tests/test_svm.py +124 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_common.py +607 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_config.py +256 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_hyperparameters.py +111 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_memory_usage.py +335 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_monkeypatch.py +269 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_n_jobs_support.py +111 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_parallel.py +48 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_patching.py +418 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability.py +335 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/utils/__init__.py +48 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/utils/base.py +420 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/tests/utils/spmd.py +198 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/__init__.py +19 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/_array_api.py +217 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/class_weight.py +100 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/parallel.py +97 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/tests/test_class_weight.py +69 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/tests/test_validation.py +238 -0
- scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/utils/validation.py +212 -0
- scikit_learn_intelex-2025.10.0.dist-info/LICENSE.txt +202 -0
- scikit_learn_intelex-2025.10.0.dist-info/METADATA +182 -0
- scikit_learn_intelex-2025.10.0.dist-info/RECORD +267 -0
- scikit_learn_intelex-2025.10.0.dist-info/WHEEL +5 -0
- scikit_learn_intelex-2025.10.0.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,615 @@
|
|
|
1
|
+
# ==============================================================================
|
|
2
|
+
# Copyright Contributors to the oneDAL Project
|
|
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
|
+
"""Sklearnex module estimator design guide and example.
|
|
18
|
+
|
|
19
|
+
This can be used as a foundation for developing other estimators. Most
|
|
20
|
+
comments guiding code development should be removed if reused unless
|
|
21
|
+
pertinent to the derivative implementation."""
|
|
22
|
+
import numpy as np
|
|
23
|
+
import scipy.sparse as sp
|
|
24
|
+
from sklearn.dummy import DummyRegressor as _sklearn_DummyRegressor
|
|
25
|
+
from sklearn.utils.validation import check_is_fitted
|
|
26
|
+
|
|
27
|
+
from daal4py.sklearn._n_jobs_support import control_n_jobs
|
|
28
|
+
from daal4py.sklearn._utils import daal_check_version, sklearn_check_version
|
|
29
|
+
from onedal._device_offload import support_input_format
|
|
30
|
+
from onedal.dummy import DummyEstimator as onedal_DummyEstimator
|
|
31
|
+
|
|
32
|
+
from .._device_offload import dispatch
|
|
33
|
+
from .._utils import PatchingConditionsChain
|
|
34
|
+
from ..base import oneDALEstimator
|
|
35
|
+
from ..utils._array_api import enable_array_api, get_namespace
|
|
36
|
+
from ..utils.validation import validate_data
|
|
37
|
+
|
|
38
|
+
################
|
|
39
|
+
# IMPORT NOTES #
|
|
40
|
+
################
|
|
41
|
+
#
|
|
42
|
+
# 1) All sklearnex estimators must inherit oneDALestimator and the sklearn
|
|
43
|
+
# estimator that it is replicating (i.e. before in the mro). If there is
|
|
44
|
+
# not an equivalent sklearn estimator, then sklearn's BaseEstimator must be
|
|
45
|
+
# inherited.
|
|
46
|
+
#
|
|
47
|
+
# 2) ``check_is_fitted`` is required for any method in an estimator which
|
|
48
|
+
# requires first calling ``fit`` or ``partial_fit``. This is a sklearn
|
|
49
|
+
# requirement.
|
|
50
|
+
#
|
|
51
|
+
# 3) Every estimator should be decorated by ``control_n_jobs`` to properly
|
|
52
|
+
# create parallelization control for the oneDAL library via the ``n_jobs``
|
|
53
|
+
# parameter. This parameter is added to ``__init__`` automatically.
|
|
54
|
+
#
|
|
55
|
+
# 4) For compatibility reasons, ``daal_check_version`` and
|
|
56
|
+
# ``sklearn_check_version`` add or remove capabilities based on the installed
|
|
57
|
+
# oneDAL library and scikit-learn package. This is often necessary for the
|
|
58
|
+
# state of oneDAL development and scikit-learn characteristics. This should
|
|
59
|
+
# be used at import time instead of run time whenever possible/ practical.
|
|
60
|
+
#
|
|
61
|
+
# 5) If a sklearn estimator is imported, it must have the ``_sklearn_``
|
|
62
|
+
# prefix added upon import in order to prevent its discovery, highlight
|
|
63
|
+
# its nature as private, and prevent a namespace collision. Any onedal
|
|
64
|
+
# imported estimator should similarly have the ``onedal_`` prefix added
|
|
65
|
+
# (as it should have the same name as the sklearnex estimator).
|
|
66
|
+
#
|
|
67
|
+
# 6) ``dispatch`` is a key central function for evaluating data with either
|
|
68
|
+
# oneDAL or sklearn. All oneDAL algorithms which are to be directly used
|
|
69
|
+
# should be accessed via this function. It should not be used unless a
|
|
70
|
+
# call to a onedal estimator occurs.
|
|
71
|
+
#
|
|
72
|
+
# 7) ``PatchingConditionsChain`` is used in conjunction with ``dispatch``
|
|
73
|
+
# and methods ``_onedal_cpu_supported`` and ``_onedal_gpu_supported`` to
|
|
74
|
+
# evaluate if the required evaluation on data is possible with oneDAL or
|
|
75
|
+
# sklearn.
|
|
76
|
+
#
|
|
77
|
+
# 8) ``get_namespace`` is key for array_api support, which yields the
|
|
78
|
+
# namespace associated with the given array for use in data conversion
|
|
79
|
+
# necessary for to and from oneDAL. An internal version is preferred due to
|
|
80
|
+
# limitations in sklearn versions and specific DPEX data framework support
|
|
81
|
+
# (see dpctl tensors and dpnp).
|
|
82
|
+
#
|
|
83
|
+
# 9) ``validate_data`` checks data quality and estimator status before
|
|
84
|
+
# evaluating the function. This replicates a sklearn functionality with key
|
|
85
|
+
# performance changes implemented in oneDAL and therefore should only be
|
|
86
|
+
# imported from sklearnex and not sklearn.
|
|
87
|
+
#
|
|
88
|
+
# 10) All estimators require validation of the parameters given at
|
|
89
|
+
# initialization. This aspect was introduced in sklearn 1.2, any additional
|
|
90
|
+
# parameters must extend the dictionary for checking. This validation
|
|
91
|
+
# normally occurs in the ``fit`` method.
|
|
92
|
+
#
|
|
93
|
+
|
|
94
|
+
##########################
|
|
95
|
+
# METHOD HIERARCHY NOTES #
|
|
96
|
+
##########################
|
|
97
|
+
#
|
|
98
|
+
# Sklearnex estimator methods can be thought of in 3 major tiers.
|
|
99
|
+
#
|
|
100
|
+
# Tier 1: Methods which offload to oneDAL using ``dispatch``. Typical
|
|
101
|
+
# examples are ``fit`` and ``predict``. They use a direct equivalent oneDAL
|
|
102
|
+
# function for evaluation. These methods are of highest priority and have
|
|
103
|
+
# performance benchmark requirements.
|
|
104
|
+
#
|
|
105
|
+
# Tier 2: Methods that use a Tier 1 method with additional Python
|
|
106
|
+
# calculations (usually a sklearn method or applied math function). Examples
|
|
107
|
+
# are ``kneighbors_graph`` and ``predict_log_proba``. Oftentimes the
|
|
108
|
+
# additional calculations are trivial, meaning benchmarking is not required.
|
|
109
|
+
#
|
|
110
|
+
# Tier 3: Methods which directly use sklearn functionality. Typically these
|
|
111
|
+
# can be directly inherited, but can be problematic with respect to other
|
|
112
|
+
# framework support. These can be wrapped with the sklearnex function
|
|
113
|
+
# ``wrap_output_data`` to guarantee array API, dpctl tensor, and dpnp
|
|
114
|
+
# support but should be addressed with care/guidance in a case-by-case
|
|
115
|
+
# basis.
|
|
116
|
+
#
|
|
117
|
+
# When the sklearnex method is replacing an inherited sklearn method, it
|
|
118
|
+
# must match the method signature exactly. For sklearnex-only estimators,
|
|
119
|
+
# attempt to match convention to sklearn estimators which are closely related.
|
|
120
|
+
|
|
121
|
+
########################
|
|
122
|
+
# CONTROL_N_JOBS NOTES #
|
|
123
|
+
########################
|
|
124
|
+
#
|
|
125
|
+
# All tier 1 methods should be in the decorated_methods list for oneDAL
|
|
126
|
+
# parallelism control. In general, changes to oneDAL parallelism should only
|
|
127
|
+
# be done once per public method call. This may mean some tier 2 methods
|
|
128
|
+
# must be added to the list along with some restructuring of the related
|
|
129
|
+
# tier 1 methods. An illustrative example could be an estimator which
|
|
130
|
+
# implements ``fit_transform`` where combining ``fit`` and ``transform``
|
|
131
|
+
# tier 1 methods may set n_jobs twice.
|
|
132
|
+
|
|
133
|
+
|
|
134
|
+
# enable_array_api enables the sklearnex code to work with and directly pass
|
|
135
|
+
# array_api and dpep frameworks data (dpnp, dpctl tensors, and pytorch for
|
|
136
|
+
# example) to the oneDAL backend
|
|
137
|
+
@enable_array_api
|
|
138
|
+
@control_n_jobs(decorated_methods=["fit", "predict"])
|
|
139
|
+
class DummyRegressor(oneDALEstimator, _sklearn_DummyRegressor):
|
|
140
|
+
# All sklearnex estimators must inherit a sklearn estimator, sklearnex-
|
|
141
|
+
# only estimators are shown by the inheritance of sklearn's
|
|
142
|
+
# BaseEstimator. Additionally, inherited oneDALEstimator for estimators
|
|
143
|
+
# without a sklearn equivalent must occur directly before BaseEstimator
|
|
144
|
+
# in the mro.
|
|
145
|
+
|
|
146
|
+
##################################
|
|
147
|
+
# GENERAL ESTIMATOR DESIGN NOTES #
|
|
148
|
+
##################################
|
|
149
|
+
#
|
|
150
|
+
# As a rule conform to sklearn design rules as much as possible
|
|
151
|
+
# (https://scikit-learn.org/stable/developers/develop.html)
|
|
152
|
+
# This includes inheriting the proper sklearn Mixin classes depending
|
|
153
|
+
# on the sklearnex estimator functionality.
|
|
154
|
+
#
|
|
155
|
+
# All estimators should be defined in a Python file located in a folder
|
|
156
|
+
# limited to the folder names in this directory:
|
|
157
|
+
# https://github.com/scikit-learn/scikit-learn/tree/main/sklearn
|
|
158
|
+
# All estimators should be properly added into the patching map located
|
|
159
|
+
# in sklearnex/dispatcher.py following the convention made there. This
|
|
160
|
+
# is important for having the estimator properly tested and available
|
|
161
|
+
# in sklearn.
|
|
162
|
+
#
|
|
163
|
+
# Sklearnex estimators follow a Matryoshka doll pattern with respect to
|
|
164
|
+
# the underlying oneDAL library:
|
|
165
|
+
#
|
|
166
|
+
# - The sklearnex estimator is a public-facing API which mimics sklearn.
|
|
167
|
+
#
|
|
168
|
+
# - The onedal estimator object which determines and sets characteristics
|
|
169
|
+
# with respect to oneDAL offloading (including but not limited to
|
|
170
|
+
# parameters, SYCL queue, data and result conversion).
|
|
171
|
+
#
|
|
172
|
+
# - The pybind11 interface objects to oneDAL C++ objects (inputs,
|
|
173
|
+
# results, and methods).
|
|
174
|
+
#
|
|
175
|
+
# These 3 objects interact in the following way: sklearnex estimators
|
|
176
|
+
# will create another estimator, defined in the ``onedal`` module, for
|
|
177
|
+
# having a Python interface with oneDAL. Finally, this Python object
|
|
178
|
+
# will use pybind11 to call oneDAL directly via pybind11-generated
|
|
179
|
+
# objects and functions This is known as the ``backend``. These are
|
|
180
|
+
# separate entities and do not inherit from one another. The clear
|
|
181
|
+
# separation has utility so long that the following rules are followed:
|
|
182
|
+
#
|
|
183
|
+
# 1) All conformance to sklearn should happen in sklearnex estimators,
|
|
184
|
+
# with all variations between the supported sklearn versions handled
|
|
185
|
+
# there. This includes transforming result data into a format which
|
|
186
|
+
# matches sklearn. This is done to minimize and focus maintenance with
|
|
187
|
+
# respect to sklearn to the sklearnex module.
|
|
188
|
+
#
|
|
189
|
+
# 2) The onedal estimator handles necessary data conversion and
|
|
190
|
+
# preparation for invoking calls to onedal. These objects should not be
|
|
191
|
+
# influenced by sklearn design or have any sklearn version dependent
|
|
192
|
+
# characteristics. Users should be able to use these objects directly
|
|
193
|
+
# to fit data without sklearn, giving the ability to use raw data
|
|
194
|
+
# directly and avoiding sklearn pre-processing checks as necessary.
|
|
195
|
+
#
|
|
196
|
+
# 3) Pybind11 interfaces should not be made public to the user unless
|
|
197
|
+
# absolutely necessary, as operation there assumes checks in the other
|
|
198
|
+
# objects have been sufficiently carried out. In most circumstances, the
|
|
199
|
+
# pybind11 interface should be invoked by the Python onedal estimator
|
|
200
|
+
# object.
|
|
201
|
+
#
|
|
202
|
+
# 4) If the estimator replicates/inherits from a sklearn estimator,
|
|
203
|
+
# then only implemented public methods should be those which override
|
|
204
|
+
# those from the sklearn estimator. The sklearn method should only be
|
|
205
|
+
# overridden if an equivalent oneDAL-accelerated capability exists
|
|
206
|
+
# following the tier system described below. If it is sklearnex only,
|
|
207
|
+
# then it should try to follow sklearn conventions of sklearn estimators
|
|
208
|
+
# which are most closely related (e.g. IncrementalPCA for incremental
|
|
209
|
+
# estimators). NOTE: as per the sklearn design rules, all estimator
|
|
210
|
+
# attributes with trailing underscores are return values and are of
|
|
211
|
+
# some type of data (and therefore not themselves oneDAL-accelerated).
|
|
212
|
+
#
|
|
213
|
+
# 5) Fitted attributes of the related scikit-learn estimator which are not
|
|
214
|
+
# defined or calculated by the oneDAL estimator still must be set in the
|
|
215
|
+
# scikit-learn-intelex estimator to plausible values. These can be either
|
|
216
|
+
# derived from available oneDAL estimator data or set to hardcoded values.
|
|
217
|
+
#
|
|
218
|
+
#
|
|
219
|
+
# Information about the onedal estimators/objects can be found in an
|
|
220
|
+
# equivalent class file in the onedal module.
|
|
221
|
+
|
|
222
|
+
#######################
|
|
223
|
+
# DOCUMENTATION NOTES #
|
|
224
|
+
#######################
|
|
225
|
+
#
|
|
226
|
+
# All public methods (i.e. without leading underscores) should have
|
|
227
|
+
# documentation which conforms to the numpy-doc standard. Generally
|
|
228
|
+
# if a defined method replaces an inherited Scikit-Learn estimator
|
|
229
|
+
# method, the ``__doc__`` attribute should be re-applied to the new
|
|
230
|
+
# implementation. Any new additional characteristics compared to the
|
|
231
|
+
# equivalent sklearn estimator should be appended to the sklearn doc
|
|
232
|
+
# string.
|
|
233
|
+
#
|
|
234
|
+
# When the estimator is added to the patching map in
|
|
235
|
+
# sklearnex/dispatcher.py, it must be equivalently added to the support
|
|
236
|
+
# table located in doc/sources/algorithms.rst if replicating an sklearn
|
|
237
|
+
# estimator. If it is unique to sklearnex, it must be added to
|
|
238
|
+
# docs/sources/non-scikit-algorithms.rst instead.
|
|
239
|
+
|
|
240
|
+
# This is required as part of sklearn conformance, which does checking
|
|
241
|
+
# of parameters set in __init__ when calling self.validate_params (should
|
|
242
|
+
# only be in a fit or fit-derived call)
|
|
243
|
+
if sklearn_check_version("1.2"):
|
|
244
|
+
_parameter_constraints: dict = {**_sklearn_DummyRegressor._parameter_constraints}
|
|
245
|
+
|
|
246
|
+
def __init__(self, *, strategy="mean", constant=None, quantile=None):
|
|
247
|
+
# Object instantiation is strictly limited by sklearn. It is only
|
|
248
|
+
# allowed to take the keyword arguments and store them as
|
|
249
|
+
# attributes with the same name. When replicating a sklearn
|
|
250
|
+
# estimator, it may be possible to use the inherited version of
|
|
251
|
+
# ``__init__`` from sklearn. The prototype uses defined parameters
|
|
252
|
+
# to highlight the way parameters are set. Controlled by sklearn
|
|
253
|
+
# test_common.py testing.
|
|
254
|
+
#
|
|
255
|
+
# The signature of the __init__ must match the sklearn estimator
|
|
256
|
+
# that it replicates (and is verified in test_patching.py)
|
|
257
|
+
self.strategy = strategy
|
|
258
|
+
self.constant = constant
|
|
259
|
+
self.quantile = quantile
|
|
260
|
+
|
|
261
|
+
# To generalize for spmd and other use cases, the constructor of the
|
|
262
|
+
# onedal estimator should be set as an attribute of the class
|
|
263
|
+
_onedal_DummyEstimator = staticmethod(onedal_DummyEstimator)
|
|
264
|
+
|
|
265
|
+
############################
|
|
266
|
+
# TIER 1 METHOD FLOW NOTES #
|
|
267
|
+
############################
|
|
268
|
+
#
|
|
269
|
+
# Some knowledge of the process flow from the sklearnex perspective is
|
|
270
|
+
# necessary to understand how to implement an estimator. For Tier 1
|
|
271
|
+
# methods, the general process is as follows:
|
|
272
|
+
#
|
|
273
|
+
# 1) If a method which requires a fitted estimator, the method must
|
|
274
|
+
# call ``check_is_fitted`` before calling ``dispatch``. This verifies
|
|
275
|
+
# that aspects of the fit are available for analysis (whether oneDAL
|
|
276
|
+
# may be used or not), usually this means specific instance attributes
|
|
277
|
+
# with trailing underscores.
|
|
278
|
+
#
|
|
279
|
+
# 2) ``dispatch`` is called. This takes the estimator object, method
|
|
280
|
+
# name, and the two possible evaluation branches and proceeds to call
|
|
281
|
+
# ``_onedal_gpu_supported`` if a SYCL queue is found or set via the
|
|
282
|
+
# target offload config. Otherwise ``_onedal_cpu_supported`` is
|
|
283
|
+
# called.
|
|
284
|
+
#
|
|
285
|
+
# 3) ``_onedal_gpu_supported`` or ``_onedal_cpu_supported`` creates a
|
|
286
|
+
# PatchingConditionsChain object, takes the input data and estimator
|
|
287
|
+
# parameters, and evaluates whether the estimator and data can be run
|
|
288
|
+
# using oneDAL. This information is logged to the `sklearnex` logger
|
|
289
|
+
# via central code (e.g. not by the estimator) in sklearnex.
|
|
290
|
+
#
|
|
291
|
+
# 4) Either sklearn is called, or a object from onedal is created and
|
|
292
|
+
# called using the input data. This process is handled in a function
|
|
293
|
+
# which has the prefix "_onedal_" followed by the method name. When
|
|
294
|
+
# fitting data, the returned onedal estimator object is stored as the
|
|
295
|
+
# ``_onedal_estimator`` attribute.
|
|
296
|
+
#
|
|
297
|
+
# 5) Result data is returned from the estimator if necessary. Attributes
|
|
298
|
+
# from the onedal estimator are copied over to the sklearnex estimator.
|
|
299
|
+
|
|
300
|
+
def fit(self, X, y, sample_weight=None):
|
|
301
|
+
# Parameter validation must be done before calls to dispatch. This
|
|
302
|
+
# guarantees that the sklearn and onedal use of parameters are
|
|
303
|
+
# properly typed and valued.
|
|
304
|
+
if sklearn_check_version("1.2"):
|
|
305
|
+
self._validate_params()
|
|
306
|
+
|
|
307
|
+
# only arguments from the method signature are passed to
|
|
308
|
+
# ``_onedal_*_supported`` and not kwargs. The parameters of the
|
|
309
|
+
# estimator are available by default as they are instance attributes.
|
|
310
|
+
# The choice between sklearn and onedal is based off of the args,
|
|
311
|
+
# and not the keyword arguments.
|
|
312
|
+
dispatch(
|
|
313
|
+
self,
|
|
314
|
+
"fit",
|
|
315
|
+
{
|
|
316
|
+
"onedal": self.__class__._onedal_fit,
|
|
317
|
+
"sklearn": _sklearn_DummyRegressor.fit,
|
|
318
|
+
},
|
|
319
|
+
X,
|
|
320
|
+
y,
|
|
321
|
+
sample_weight,
|
|
322
|
+
)
|
|
323
|
+
# For sklearnex-only estimators, _onedal_*_supported should either
|
|
324
|
+
# pass or throw an exception. This means the sklearn branch is never
|
|
325
|
+
# used. In general, the two branches must be the class methods. The
|
|
326
|
+
# parameters which are passed as arguments are given to
|
|
327
|
+
# _onedal_*_supported. In this example, the ``sample_weight`` keyword
|
|
328
|
+
# argument in the ``fit`` signature is set as an argument to
|
|
329
|
+
# ``dispatch`` so that it can be properly sent to _onedal_*_supported
|
|
330
|
+
# for checking oneDAL support.
|
|
331
|
+
|
|
332
|
+
# methods which do not return a result should return self (sklearn
|
|
333
|
+
# standard)
|
|
334
|
+
return self
|
|
335
|
+
|
|
336
|
+
def predict(self, X, return_std=False):
|
|
337
|
+
# note return_std is a special aspect of the sklearn version of this
|
|
338
|
+
# estimator, normally the signatures is just predict(self, X)
|
|
339
|
+
|
|
340
|
+
check_is_fitted(self) # first check if fitting has occurred
|
|
341
|
+
# No need to do another parameter check. While they are modifiable
|
|
342
|
+
# in sklearn and in sklearnex, the parameters should never be
|
|
343
|
+
# changed by hand.
|
|
344
|
+
return dispatch(
|
|
345
|
+
self,
|
|
346
|
+
"predict",
|
|
347
|
+
{
|
|
348
|
+
"onedal": self.__class__._onedal_predict,
|
|
349
|
+
"sklearn": _sklearn_DummyRegressor.predict,
|
|
350
|
+
},
|
|
351
|
+
X,
|
|
352
|
+
return_std=return_std, # not important for patching, set as kwarg
|
|
353
|
+
)
|
|
354
|
+
# return value will be handled by self._onedal_predict
|
|
355
|
+
|
|
356
|
+
def _onedal_fit(self, X, y, sample_weight=None, queue=None):
|
|
357
|
+
# The queue attribute must be added as the last kwarg to all
|
|
358
|
+
# onedal-facing functions. The SYCL queue is acquired in
|
|
359
|
+
# ``dispatch`` and is set there before calling ``_onedal_``-prefix
|
|
360
|
+
# methods.
|
|
361
|
+
|
|
362
|
+
# The first step is to always acquire the namespace of input data
|
|
363
|
+
# This is important for getting the proper data types and possibly
|
|
364
|
+
# other conversions.
|
|
365
|
+
xp, _ = get_namespace(X, y)
|
|
366
|
+
|
|
367
|
+
# The second step must always be to validate the data.
|
|
368
|
+
# This algorithm can accept 2d y inputs (by setting multi_output).
|
|
369
|
+
# Note the use of "sklearn_check_version". This is required in order
|
|
370
|
+
# to conform to changes which occur in sklearn over the supported
|
|
371
|
+
# versions. The conformance to sklearn should occur in this object,
|
|
372
|
+
# therefore this function should not be used in the onedal module.
|
|
373
|
+
# This conformance example is specific to the Dummy Estimators.
|
|
374
|
+
X, y = validate_data(
|
|
375
|
+
self,
|
|
376
|
+
X,
|
|
377
|
+
y,
|
|
378
|
+
dtype=[xp.float64, xp.float32],
|
|
379
|
+
multi_output=True,
|
|
380
|
+
y_numeric=True,
|
|
381
|
+
ensure_2d=sklearn_check_version("1.2"),
|
|
382
|
+
)
|
|
383
|
+
# validate_data does several things:
|
|
384
|
+
# 1) If not in the proper namespace (depending on array_api configs)
|
|
385
|
+
# convert the data to the proper data format (default: numpy array)
|
|
386
|
+
# 2) It will check additional aspects for labeled data.
|
|
387
|
+
# 3) It will convert the arrays to the proper data type, which for
|
|
388
|
+
# oneDAL is usually float64 or float32, but can also be int32 in
|
|
389
|
+
# rare circumstances.
|
|
390
|
+
# kwargs often are used for sklearn's ``check_array``. It is best
|
|
391
|
+
# to often use the values set for sklearn for the equivalent same
|
|
392
|
+
# step. This is not guaranteed and requires care by the developer.
|
|
393
|
+
# For example, ``ensure_all_finite`` is set to false in this case
|
|
394
|
+
# for the nature of the class, but would otherwise be unset.
|
|
395
|
+
|
|
396
|
+
# Conformance to sklearn's DummyRegressor
|
|
397
|
+
if y.ndim == 1:
|
|
398
|
+
y = xp.reshape(y, (-1, 1))
|
|
399
|
+
self.n_outputs_ = y.shape[1]
|
|
400
|
+
|
|
401
|
+
# In the ``fit`` method, a Python onedal estimator object is
|
|
402
|
+
# generated.
|
|
403
|
+
self._onedal_estimator = self._onedal_DummyEstimator(constant=self.constant)
|
|
404
|
+
# queue must be passed to the onedal Python estimator object
|
|
405
|
+
# though this may change in the future as a requirement.
|
|
406
|
+
self._onedal_estimator.fit(X, y, queue=queue)
|
|
407
|
+
|
|
408
|
+
# set attributes from _onedal_estimator to sklearnex estimator
|
|
409
|
+
# It is allowed to have a separate private function to do this step
|
|
410
|
+
# Below is only an example, but should be all the attributes
|
|
411
|
+
# available from the same sklearn estimator (if not sklearnex-only)
|
|
412
|
+
# after fitting.
|
|
413
|
+
self.constant_ = self._onedal_estimator.constant_
|
|
414
|
+
# See sklearn conventions about trailing underscores for fitted
|
|
415
|
+
# values.
|
|
416
|
+
|
|
417
|
+
# sklearn conformance
|
|
418
|
+
if self.n_outputs_ != 1 and self.constant_.shape[0] != y.shape[1]:
|
|
419
|
+
raise ValueError(
|
|
420
|
+
"Constant target value should have shape (%d, 1)." % y.shape[1]
|
|
421
|
+
)
|
|
422
|
+
|
|
423
|
+
def _onedal_predict(self, X, return_std=None, queue=None):
|
|
424
|
+
# The first step is to always acquire the namespace of input data
|
|
425
|
+
# This is important for getting the proper data types and possibly
|
|
426
|
+
# other conversions.
|
|
427
|
+
xp, _ = get_namespace(X)
|
|
428
|
+
|
|
429
|
+
# The second step must always be to validate the data.
|
|
430
|
+
# Not checking of X as 2d is sklearn conformance specific to matching
|
|
431
|
+
# the Scikit-Learn DummyRegressor and is not normally required.
|
|
432
|
+
X = validate_data(
|
|
433
|
+
self,
|
|
434
|
+
X,
|
|
435
|
+
dtype=[xp.float64, xp.float32],
|
|
436
|
+
reset=False,
|
|
437
|
+
ensure_2d=sklearn_check_version("1.2"),
|
|
438
|
+
)
|
|
439
|
+
# queue must be sent back to the onedal Python estimator object
|
|
440
|
+
y = self._onedal_estimator.predict(X, queue=queue)
|
|
441
|
+
|
|
442
|
+
if self.n_outputs_ == 1:
|
|
443
|
+
y = xp.reshape(y, (-1,))
|
|
444
|
+
|
|
445
|
+
y_std = xp.zeros_like(y)
|
|
446
|
+
|
|
447
|
+
return (y, y_std) if return_std else y
|
|
448
|
+
|
|
449
|
+
def _onedal_cpu_supported(self, method_name, *data):
|
|
450
|
+
# All estimators must have the following two functions with exactly
|
|
451
|
+
# these signatures. method_name is a string which must match one
|
|
452
|
+
# of the tier 1 methods of the estimator. The logic located here
|
|
453
|
+
# will inspect attributes of the data and the estimator to see if
|
|
454
|
+
# sklearn
|
|
455
|
+
|
|
456
|
+
# Begin by generating the PatchingConditionsChain, which should
|
|
457
|
+
# require modifying the secondary module to match the folder as in
|
|
458
|
+
# the example below.
|
|
459
|
+
patching_status = PatchingConditionsChain(
|
|
460
|
+
f"sklearnex.test.{self.__class__.__name__}.{method_name}"
|
|
461
|
+
)
|
|
462
|
+
# The conditions are specifically tailored to compares aspects
|
|
463
|
+
# of the oneDAL implementation to the aspects of the sklearn
|
|
464
|
+
# estimator. For example, oneDAL may not support sparse inputs
|
|
465
|
+
# where sklearn might, that would need to be checked with
|
|
466
|
+
# scipy.sparse.issparse(X). In general the conditions will
|
|
467
|
+
# correspond to information in the metadata and/or the estimator
|
|
468
|
+
# parameters.
|
|
469
|
+
#
|
|
470
|
+
# In no circumstance should ``validate_data`` be called here or
|
|
471
|
+
# in _onedal_gpu_supoorted to get the data into the proper form.
|
|
472
|
+
if method_name == "fit":
|
|
473
|
+
(X, y, sample_weight) = data
|
|
474
|
+
xp, _ = get_namespace(X, y)
|
|
475
|
+
|
|
476
|
+
# the PatchingConditionsChain is validated using
|
|
477
|
+
# ``and_conditions``, use of ``or_conditions`` is highly
|
|
478
|
+
# discouraged. The following checks are specific to this example
|
|
479
|
+
# and must be tailored to the specific estimator implementation.
|
|
480
|
+
patching_status.and_conditions(
|
|
481
|
+
[
|
|
482
|
+
(
|
|
483
|
+
not sp.issparse(X),
|
|
484
|
+
"sparse data is not supported",
|
|
485
|
+
),
|
|
486
|
+
(
|
|
487
|
+
self.strategy == "constant",
|
|
488
|
+
"only the constant strategy is supported",
|
|
489
|
+
),
|
|
490
|
+
(
|
|
491
|
+
not hasattr(X, "dtype") or X.dtype in (xp.float64, xp.float32),
|
|
492
|
+
"oneDAL operates with float64 and float32 inputs",
|
|
493
|
+
),
|
|
494
|
+
(
|
|
495
|
+
isinstance(self.constant, (int, float)),
|
|
496
|
+
"only basic Python types are supported",
|
|
497
|
+
),
|
|
498
|
+
(sample_weight is None, "sample_weight is not supported"),
|
|
499
|
+
]
|
|
500
|
+
)
|
|
501
|
+
|
|
502
|
+
elif method_name == "predict":
|
|
503
|
+
# There is a very important subtlety about the ``dispatch`` function
|
|
504
|
+
# and how it interacts with ``_onedal_*_supported`` in that only args
|
|
505
|
+
# are used in these methods to evaluate oneDAL support. This means
|
|
506
|
+
# that kwargs to the public API may become args in the call to dispatch
|
|
507
|
+
# In this case, return_std (from predict) does not impact oneDAL, and
|
|
508
|
+
# is kept as a kwarg in the ``dispatch`` call in ``predict``. In ``fit``
|
|
509
|
+
# the kwarg ``sample_weight`` is important for evaluating oneDAL support
|
|
510
|
+
# and is passed as an arg.
|
|
511
|
+
(X,) = data
|
|
512
|
+
|
|
513
|
+
patching_status.and_conditions(
|
|
514
|
+
[
|
|
515
|
+
(hasattr(self, "_onedal_estimator"), "oneDAL model was not trained."),
|
|
516
|
+
(
|
|
517
|
+
not sp.issparse(X),
|
|
518
|
+
"sparse data is not supported",
|
|
519
|
+
),
|
|
520
|
+
]
|
|
521
|
+
)
|
|
522
|
+
|
|
523
|
+
# the patching_status object should be returned
|
|
524
|
+
return patching_status
|
|
525
|
+
|
|
526
|
+
def _onedal_gpu_supported(self, method_name, *data):
|
|
527
|
+
# This method will only be called if it is expected to try and use
|
|
528
|
+
# a SYCL-enabled GPU. See _onedal_cpu_supported for initial
|
|
529
|
+
# implementation notes. This should follow the same procedures
|
|
530
|
+
# dicatated by the characteristics of GPU oneDAL algorithm
|
|
531
|
+
patching_status = PatchingConditionsChain(
|
|
532
|
+
f"sklearnex.test.{self.__class__.__name__}.{method_name}"
|
|
533
|
+
)
|
|
534
|
+
if method_name == "fit":
|
|
535
|
+
(X, y, sample_weight) = data
|
|
536
|
+
xp, _ = get_namespace(X, y)
|
|
537
|
+
|
|
538
|
+
patching_status.and_conditions(
|
|
539
|
+
[
|
|
540
|
+
(
|
|
541
|
+
not sp.issparse(X),
|
|
542
|
+
"sparse data is not supported",
|
|
543
|
+
),
|
|
544
|
+
(
|
|
545
|
+
self.strategy == "constant",
|
|
546
|
+
"only the constant strategy is supported",
|
|
547
|
+
),
|
|
548
|
+
(
|
|
549
|
+
not hasattr(X, "dtype") or X.dtype in (xp.float64, xp.float32),
|
|
550
|
+
"oneDAL operates on float64 and float32 inputs",
|
|
551
|
+
),
|
|
552
|
+
(
|
|
553
|
+
isinstance(self.constant, (int, float)),
|
|
554
|
+
"only basic Python types are supported",
|
|
555
|
+
),
|
|
556
|
+
(sample_weight is None, "sample_weight is not supported"),
|
|
557
|
+
]
|
|
558
|
+
)
|
|
559
|
+
|
|
560
|
+
elif method_name == "predict":
|
|
561
|
+
(X,) = data
|
|
562
|
+
|
|
563
|
+
patching_status.and_conditions(
|
|
564
|
+
[
|
|
565
|
+
(hasattr(self, "_onedal_estimator"), "oneDAL model was not trained."),
|
|
566
|
+
(
|
|
567
|
+
not sp.issparse(X),
|
|
568
|
+
"sparse data is not supported",
|
|
569
|
+
),
|
|
570
|
+
]
|
|
571
|
+
)
|
|
572
|
+
|
|
573
|
+
# the patching_status object should be returned
|
|
574
|
+
return patching_status
|
|
575
|
+
|
|
576
|
+
# onedal estimators with onedal models which can be modified must have
|
|
577
|
+
# the necessary attributes linked. This way the state of the two
|
|
578
|
+
# estimators do not diverge as modifications could impact the inference
|
|
579
|
+
# results. This not always necessary, as some estimators generate a
|
|
580
|
+
# model for predict during fit which cannot be modified. The easiest
|
|
581
|
+
# way to check for this is if the oneDAL estimator contains a "model"
|
|
582
|
+
# method.
|
|
583
|
+
|
|
584
|
+
@property
|
|
585
|
+
def constant_(self):
|
|
586
|
+
return self._constant_
|
|
587
|
+
|
|
588
|
+
# The fitted variables match the data framework and device of the inputs.
|
|
589
|
+
# Modifications of these output attributes to different frameworks or
|
|
590
|
+
# devices may not work and are not monitored by the oneDAL estimator.
|
|
591
|
+
# This matches behavior which occurs in sklearn and therefore is up
|
|
592
|
+
# to the user to guarantee operation, especially in methods which depend
|
|
593
|
+
# on fitted estimators and attributes (like `transform` or `predict`).
|
|
594
|
+
@constant_.setter
|
|
595
|
+
def constant_(self, value):
|
|
596
|
+
self._constant_ = value
|
|
597
|
+
if hasattr(self, "_onedal_estimator"):
|
|
598
|
+
self._onedal_estimator._onedal_model = None
|
|
599
|
+
self._onedal_estimator.constant_ = value
|
|
600
|
+
|
|
601
|
+
@constant_.deleter
|
|
602
|
+
def constant_(self):
|
|
603
|
+
del self._constant_
|
|
604
|
+
|
|
605
|
+
# score is a tier 3 method in this case. Wrap with ``support_input_format`` for array
|
|
606
|
+
# api support.
|
|
607
|
+
score = support_input_format(_sklearn_DummyRegressor.score)
|
|
608
|
+
|
|
609
|
+
# Docstrings should be inherited from the sklearn estimator if possible
|
|
610
|
+
# In sklearnex-only estimators, they should be written from scratch
|
|
611
|
+
# using the numpy-doc standard.
|
|
612
|
+
__doc__ = _sklearn_DummyRegressor.__doc__
|
|
613
|
+
fit.__doc__ = _sklearn_DummyRegressor.fit.__doc__
|
|
614
|
+
predict.__doc__ = _sklearn_DummyRegressor.predict.__doc__
|
|
615
|
+
score.__doc__ = _sklearn_DummyRegressor.score.__doc__
|
scikit_learn_intelex-2025.10.0.data/data/Lib/site-packages/sklearnex/dummy/tests/test_dummy.py
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# ===============================================================================
|
|
2
|
+
# Copyright Contributors to the oneDAL Project
|
|
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 numpy as np
|
|
18
|
+
import pytest
|
|
19
|
+
|
|
20
|
+
from daal4py.sklearn._utils import sklearn_check_version
|
|
21
|
+
from onedal.tests.utils._dataframes_support import (
|
|
22
|
+
_as_numpy,
|
|
23
|
+
_convert_to_dataframe,
|
|
24
|
+
get_dataframes_and_queues,
|
|
25
|
+
)
|
|
26
|
+
from sklearnex import config_context
|
|
27
|
+
from sklearnex.dummy import DummyRegressor
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
|
|
31
|
+
def test_sklearnex_import_DummyRegressor(dataframe, queue):
|
|
32
|
+
rng = np.random.default_rng(seed=42)
|
|
33
|
+
|
|
34
|
+
X = rng.random((10, 4))
|
|
35
|
+
y = rng.random((10,))
|
|
36
|
+
X = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
|
|
37
|
+
y = _convert_to_dataframe(y, sycl_queue=queue, target_df=dataframe)
|
|
38
|
+
est = DummyRegressor(strategy="constant", constant=np.pi).fit(X, y)
|
|
39
|
+
assert "sklearnex" in est.__module__
|
|
40
|
+
pred = _as_numpy(est.predict([[0, 0, 0, 0]]))
|
|
41
|
+
np.testing.assert_array_equal(np.pi * np.ones(pred.shape), pred)
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
@pytest.mark.skipif(
|
|
45
|
+
not sklearn_check_version("1.3"), reason="lacks sklearn array API support"
|
|
46
|
+
)
|
|
47
|
+
@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues("dpctl,dpnp"))
|
|
48
|
+
def test_fitted_attribute_conversion_DummyRegressor(dataframe, queue):
|
|
49
|
+
rng = np.random.default_rng(seed=42)
|
|
50
|
+
|
|
51
|
+
X = rng.random((10, 4))
|
|
52
|
+
y = rng.random((10,))
|
|
53
|
+
X = _convert_to_dataframe(X, sycl_queue=queue, target_df=dataframe)
|
|
54
|
+
y = _convert_to_dataframe(y, sycl_queue=queue, target_df=dataframe)
|
|
55
|
+
X_test = _convert_to_dataframe([[0, 0, 0, 0]], sycl_queue=queue, target_df=dataframe)
|
|
56
|
+
with config_context(array_api_dispatch=True):
|
|
57
|
+
est = DummyRegressor(strategy="constant", constant=np.e).fit(X, y)
|
|
58
|
+
pred = _as_numpy(est.predict(X_test))
|
|
59
|
+
|
|
60
|
+
np.testing.assert_array_equal(np.full(pred.shape, np.e), pred)
|
|
61
|
+
est.constant_ = np.ones(est.constant_.shape)
|
|
62
|
+
np.testing.assert_array_equal(np.ones(pred.shape), est.predict([[0, 0, 0, 0]]))
|