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,403 @@
|
|
|
1
|
+
# ==============================================================================
|
|
2
|
+
# Copyright 2021 Intel Corporation
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
# ==============================================================================
|
|
16
|
+
|
|
17
|
+
import warnings
|
|
18
|
+
from numbers import Number, Real
|
|
19
|
+
|
|
20
|
+
import numpy as np
|
|
21
|
+
from scipy import sparse as sp
|
|
22
|
+
from sklearn.base import ClassifierMixin
|
|
23
|
+
from sklearn.calibration import CalibratedClassifierCV
|
|
24
|
+
from sklearn.metrics import r2_score
|
|
25
|
+
from sklearn.preprocessing import LabelEncoder
|
|
26
|
+
|
|
27
|
+
from daal4py.sklearn._utils import sklearn_check_version
|
|
28
|
+
from daal4py.sklearn.utils.validation import get_requires_y_tag
|
|
29
|
+
from onedal.utils.validation import _check_array, _column_or_1d
|
|
30
|
+
|
|
31
|
+
from .._config import config_context, get_config
|
|
32
|
+
from .._utils import PatchingConditionsChain
|
|
33
|
+
from ..base import oneDALEstimator
|
|
34
|
+
from ..utils.validation import validate_data
|
|
35
|
+
|
|
36
|
+
if sklearn_check_version("1.6"):
|
|
37
|
+
from sklearn.calibration import _fit_calibrator
|
|
38
|
+
from sklearn.frozen import FrozenEstimator
|
|
39
|
+
from sklearn.utils import indexable
|
|
40
|
+
from sklearn.utils._response import _get_response_values
|
|
41
|
+
from sklearn.utils.multiclass import check_classification_targets
|
|
42
|
+
from sklearn.utils.validation import check_is_fitted
|
|
43
|
+
|
|
44
|
+
if sklearn_check_version("1.8"):
|
|
45
|
+
from ..utils._array_api import get_namespace
|
|
46
|
+
|
|
47
|
+
def _prefit_CalibratedClassifierCV_fit(self, X, y, **fit_params):
|
|
48
|
+
# This is a stop-gap solution where the cv='prefit' of CalibratedClassifierCV
|
|
49
|
+
# was removed and the single fold solution needs to be maintained. Discussion
|
|
50
|
+
# of the mathematical and performance implications of this choice can be found
|
|
51
|
+
# here: https://github.com/uxlfoundation/scikit-learn-intelex/pull/1879
|
|
52
|
+
# This is distilled from the sklearn CalibratedClassifierCV for sklearn <1.8 for
|
|
53
|
+
# use in sklearn > 1.8 to maintain performance.
|
|
54
|
+
check_classification_targets(y)
|
|
55
|
+
X, y = indexable(X, y)
|
|
56
|
+
|
|
57
|
+
estimator = self._get_estimator()
|
|
58
|
+
|
|
59
|
+
self.calibrated_classifiers_ = []
|
|
60
|
+
check_is_fitted(self.estimator, attributes=["classes_"])
|
|
61
|
+
self.classes_ = self.estimator.classes_
|
|
62
|
+
|
|
63
|
+
predictions, _ = _get_response_values(
|
|
64
|
+
estimator,
|
|
65
|
+
X,
|
|
66
|
+
response_method=["decision_function", "predict_proba"],
|
|
67
|
+
)
|
|
68
|
+
if predictions.ndim == 1:
|
|
69
|
+
# Reshape binary output from `(n_samples,)` to `(n_samples, 1)`
|
|
70
|
+
predictions = predictions.reshape(-1, 1)
|
|
71
|
+
|
|
72
|
+
if sklearn_check_version("1.8"):
|
|
73
|
+
xp, _ = get_namespace(X, y)
|
|
74
|
+
calibrated_classifier = _fit_calibrator(
|
|
75
|
+
estimator,
|
|
76
|
+
predictions,
|
|
77
|
+
y,
|
|
78
|
+
self.classes_,
|
|
79
|
+
self.method,
|
|
80
|
+
xp,
|
|
81
|
+
)
|
|
82
|
+
else:
|
|
83
|
+
calibrated_classifier = _fit_calibrator(
|
|
84
|
+
estimator,
|
|
85
|
+
predictions,
|
|
86
|
+
y,
|
|
87
|
+
self.classes_,
|
|
88
|
+
self.method,
|
|
89
|
+
)
|
|
90
|
+
self.calibrated_classifiers_.append(calibrated_classifier)
|
|
91
|
+
|
|
92
|
+
first_clf = self.calibrated_classifiers_[0].estimator
|
|
93
|
+
if hasattr(first_clf, "n_features_in_"):
|
|
94
|
+
self.n_features_in_ = first_clf.n_features_in_
|
|
95
|
+
if hasattr(first_clf, "feature_names_in_"):
|
|
96
|
+
self.feature_names_in_ = first_clf.feature_names_in_
|
|
97
|
+
return self
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
class BaseSVM(oneDALEstimator):
|
|
101
|
+
|
|
102
|
+
@property
|
|
103
|
+
def _dual_coef_(self):
|
|
104
|
+
return self._dualcoef_
|
|
105
|
+
|
|
106
|
+
@_dual_coef_.setter
|
|
107
|
+
def _dual_coef_(self, value):
|
|
108
|
+
self._dualcoef_ = value
|
|
109
|
+
if hasattr(self, "_onedal_estimator"):
|
|
110
|
+
self._onedal_estimator.dual_coef_ = value
|
|
111
|
+
if hasattr(self._onedal_estimator, "_onedal_model"):
|
|
112
|
+
del self._onedal_estimator._onedal_model
|
|
113
|
+
|
|
114
|
+
@_dual_coef_.deleter
|
|
115
|
+
def _dual_coef_(self):
|
|
116
|
+
del self._dualcoef_
|
|
117
|
+
|
|
118
|
+
@property
|
|
119
|
+
def intercept_(self):
|
|
120
|
+
return self._icept_
|
|
121
|
+
|
|
122
|
+
@intercept_.setter
|
|
123
|
+
def intercept_(self, value):
|
|
124
|
+
self._icept_ = value
|
|
125
|
+
if hasattr(self, "_onedal_estimator"):
|
|
126
|
+
self._onedal_estimator.intercept_ = value
|
|
127
|
+
if hasattr(self._onedal_estimator, "_onedal_model"):
|
|
128
|
+
del self._onedal_estimator._onedal_model
|
|
129
|
+
|
|
130
|
+
@intercept_.deleter
|
|
131
|
+
def intercept_(self):
|
|
132
|
+
del self._icept_
|
|
133
|
+
|
|
134
|
+
def _onedal_gpu_supported(self, method_name, *data):
|
|
135
|
+
patching_status = PatchingConditionsChain(f"sklearn.{method_name}")
|
|
136
|
+
patching_status.and_conditions([(False, "GPU offloading is not supported.")])
|
|
137
|
+
return patching_status
|
|
138
|
+
|
|
139
|
+
def _onedal_cpu_supported(self, method_name, *data):
|
|
140
|
+
class_name = self.__class__.__name__
|
|
141
|
+
patching_status = PatchingConditionsChain(
|
|
142
|
+
f"sklearn.svm.{class_name}.{method_name}"
|
|
143
|
+
)
|
|
144
|
+
if method_name == "fit":
|
|
145
|
+
patching_status.and_conditions(
|
|
146
|
+
[
|
|
147
|
+
(
|
|
148
|
+
self.kernel in ["linear", "rbf", "poly", "sigmoid"],
|
|
149
|
+
f'Kernel is "{self.kernel}" while '
|
|
150
|
+
'"linear", "rbf", "poly" and "sigmoid" are only supported.',
|
|
151
|
+
)
|
|
152
|
+
]
|
|
153
|
+
)
|
|
154
|
+
return patching_status
|
|
155
|
+
inference_methods = (
|
|
156
|
+
["predict", "score"]
|
|
157
|
+
if class_name.endswith("R")
|
|
158
|
+
else ["predict", "predict_proba", "decision_function", "score"]
|
|
159
|
+
)
|
|
160
|
+
if method_name in inference_methods:
|
|
161
|
+
patching_status.and_conditions(
|
|
162
|
+
[(hasattr(self, "_onedal_estimator"), "oneDAL model was not trained.")]
|
|
163
|
+
)
|
|
164
|
+
return patching_status
|
|
165
|
+
raise RuntimeError(f"Unknown method {method_name} in {class_name}")
|
|
166
|
+
|
|
167
|
+
def _compute_gamma_sigma(self, X):
|
|
168
|
+
# only run extended conversion if kernel is not linear
|
|
169
|
+
# set to a value = 1.0, so gamma will always be passed to
|
|
170
|
+
# the onedal estimator as a float type
|
|
171
|
+
if self.kernel == "linear":
|
|
172
|
+
return 1.0
|
|
173
|
+
|
|
174
|
+
if isinstance(self.gamma, str):
|
|
175
|
+
if self.gamma == "scale":
|
|
176
|
+
if sp.issparse(X):
|
|
177
|
+
# var = E[X^2] - E[X]^2
|
|
178
|
+
X_sc = (X.multiply(X)).mean() - (X.mean()) ** 2
|
|
179
|
+
else:
|
|
180
|
+
X_sc = X.var()
|
|
181
|
+
_gamma = 1.0 / (X.shape[1] * X_sc) if X_sc != 0 else 1.0
|
|
182
|
+
elif self.gamma == "auto":
|
|
183
|
+
_gamma = 1.0 / X.shape[1]
|
|
184
|
+
else:
|
|
185
|
+
raise ValueError(
|
|
186
|
+
"When 'gamma' is a string, it should be either 'scale' or "
|
|
187
|
+
"'auto'. Got '{}' instead.".format(self.gamma)
|
|
188
|
+
)
|
|
189
|
+
else:
|
|
190
|
+
if sklearn_check_version("1.1") and not sklearn_check_version("1.2"):
|
|
191
|
+
if isinstance(self.gamma, Real):
|
|
192
|
+
if self.gamma <= 0:
|
|
193
|
+
msg = (
|
|
194
|
+
f"gamma value must be > 0; {self.gamma!r} is invalid. Use"
|
|
195
|
+
" a positive number or use 'auto' to set gamma to a"
|
|
196
|
+
" value of 1 / n_features."
|
|
197
|
+
)
|
|
198
|
+
raise ValueError(msg)
|
|
199
|
+
_gamma = self.gamma
|
|
200
|
+
else:
|
|
201
|
+
msg = (
|
|
202
|
+
"The gamma value should be set to 'scale', 'auto' or a"
|
|
203
|
+
f" positive float value. {self.gamma!r} is not a valid option"
|
|
204
|
+
)
|
|
205
|
+
raise ValueError(msg)
|
|
206
|
+
else:
|
|
207
|
+
_gamma = self.gamma
|
|
208
|
+
return _gamma
|
|
209
|
+
|
|
210
|
+
def _onedal_fit_checks(self, X, y, sample_weight=None):
|
|
211
|
+
if hasattr(self, "decision_function_shape"):
|
|
212
|
+
if self.decision_function_shape not in ("ovr", "ovo", None):
|
|
213
|
+
raise ValueError(
|
|
214
|
+
f"decision_function_shape must be either 'ovr' or 'ovo', "
|
|
215
|
+
f"got {self.decision_function_shape}."
|
|
216
|
+
)
|
|
217
|
+
|
|
218
|
+
if y is None:
|
|
219
|
+
if get_requires_y_tag(self):
|
|
220
|
+
raise ValueError(
|
|
221
|
+
f"This {self.__class__.__name__} estimator "
|
|
222
|
+
f"requires y to be passed, but the target y is None."
|
|
223
|
+
)
|
|
224
|
+
# finite check occurs in onedal estimator
|
|
225
|
+
X, y = validate_data(
|
|
226
|
+
self,
|
|
227
|
+
X,
|
|
228
|
+
y,
|
|
229
|
+
dtype=[np.float64, np.float32],
|
|
230
|
+
ensure_all_finite=False,
|
|
231
|
+
accept_sparse="csr",
|
|
232
|
+
)
|
|
233
|
+
y = self._validate_targets(y)
|
|
234
|
+
sample_weight = self._get_sample_weight(X, y, sample_weight)
|
|
235
|
+
return X, y, sample_weight
|
|
236
|
+
|
|
237
|
+
def _get_sample_weight(self, X, y, sample_weight):
|
|
238
|
+
n_samples = X.shape[0]
|
|
239
|
+
dtype = X.dtype
|
|
240
|
+
if n_samples == 1:
|
|
241
|
+
raise ValueError("n_samples=1")
|
|
242
|
+
|
|
243
|
+
sample_weight = np.ascontiguousarray(
|
|
244
|
+
[] if sample_weight is None else sample_weight, dtype=np.float64
|
|
245
|
+
)
|
|
246
|
+
|
|
247
|
+
sample_weight_count = sample_weight.shape[0]
|
|
248
|
+
if sample_weight_count != 0 and sample_weight_count != n_samples:
|
|
249
|
+
raise ValueError(
|
|
250
|
+
"sample_weight and X have incompatible shapes: "
|
|
251
|
+
"%r vs %r\n"
|
|
252
|
+
"Note: Sparse matrices cannot be indexed w/"
|
|
253
|
+
"boolean masks (use `indices=True` in CV)."
|
|
254
|
+
% (len(sample_weight), X.shape)
|
|
255
|
+
)
|
|
256
|
+
|
|
257
|
+
if sample_weight_count == 0:
|
|
258
|
+
if not isinstance(self, ClassifierMixin) or self.class_weight_ is None:
|
|
259
|
+
return None
|
|
260
|
+
sample_weight = np.ones(n_samples, dtype=dtype)
|
|
261
|
+
elif isinstance(sample_weight, Number):
|
|
262
|
+
sample_weight = np.full(n_samples, sample_weight, dtype=dtype)
|
|
263
|
+
else:
|
|
264
|
+
sample_weight = _check_array(
|
|
265
|
+
sample_weight,
|
|
266
|
+
accept_sparse=False,
|
|
267
|
+
ensure_2d=False,
|
|
268
|
+
dtype=dtype,
|
|
269
|
+
order="C",
|
|
270
|
+
)
|
|
271
|
+
if sample_weight.ndim != 1:
|
|
272
|
+
raise ValueError("Sample weights must be 1D array or scalar")
|
|
273
|
+
|
|
274
|
+
if sample_weight.shape != (n_samples,):
|
|
275
|
+
raise ValueError(
|
|
276
|
+
"sample_weight.shape == {}, expected {}!".format(
|
|
277
|
+
sample_weight.shape, (n_samples,)
|
|
278
|
+
)
|
|
279
|
+
)
|
|
280
|
+
|
|
281
|
+
if np.all(sample_weight <= 0):
|
|
282
|
+
if "nusvc" in self.__module__:
|
|
283
|
+
raise ValueError("negative dimensions are not allowed")
|
|
284
|
+
else:
|
|
285
|
+
raise ValueError(
|
|
286
|
+
"Invalid input - all samples have zero or negative weights."
|
|
287
|
+
)
|
|
288
|
+
|
|
289
|
+
return sample_weight
|
|
290
|
+
|
|
291
|
+
|
|
292
|
+
class BaseSVC(BaseSVM):
|
|
293
|
+
def _compute_balanced_class_weight(self, y):
|
|
294
|
+
y_ = _column_or_1d(y)
|
|
295
|
+
classes, _ = np.unique(y_, return_inverse=True)
|
|
296
|
+
|
|
297
|
+
le = LabelEncoder()
|
|
298
|
+
y_ind = le.fit_transform(y_)
|
|
299
|
+
if not np.isin(classes, le.classes_).all():
|
|
300
|
+
raise ValueError("classes should have valid labels that are in y")
|
|
301
|
+
|
|
302
|
+
recip_freq = len(y_) / (len(le.classes_) * np.bincount(y_ind).astype(np.float64))
|
|
303
|
+
return recip_freq[le.transform(classes)]
|
|
304
|
+
|
|
305
|
+
def _fit_proba(self, X, y, sample_weight=None, queue=None):
|
|
306
|
+
# TODO: rewrite this method when probabilities output is implemented in oneDAL
|
|
307
|
+
|
|
308
|
+
# LibSVM uses the random seed to control cross-validation for probability generation
|
|
309
|
+
# CalibratedClassifierCV with "prefit" does not use an RNG nor a seed. This may
|
|
310
|
+
# impact users without their knowledge, so display a warning.
|
|
311
|
+
if self.random_state is not None:
|
|
312
|
+
warnings.warn(
|
|
313
|
+
"random_state does not influence oneDAL SVM results",
|
|
314
|
+
RuntimeWarning,
|
|
315
|
+
)
|
|
316
|
+
|
|
317
|
+
params = self.get_params()
|
|
318
|
+
params["probability"] = False
|
|
319
|
+
params["decision_function_shape"] = "ovr"
|
|
320
|
+
clf_base = self.__class__(**params)
|
|
321
|
+
|
|
322
|
+
# We use stock metaestimators below, so the only way
|
|
323
|
+
# to pass a queue is using config_context.
|
|
324
|
+
cfg = get_config()
|
|
325
|
+
cfg["target_offload"] = queue
|
|
326
|
+
with config_context(**cfg):
|
|
327
|
+
clf_base.fit(X, y)
|
|
328
|
+
|
|
329
|
+
# Forced use of FrozenEstimator starting in sklearn 1.6
|
|
330
|
+
if sklearn_check_version("1.6"):
|
|
331
|
+
clf_base = FrozenEstimator(clf_base)
|
|
332
|
+
|
|
333
|
+
self.clf_prob = CalibratedClassifierCV(
|
|
334
|
+
clf_base,
|
|
335
|
+
ensemble=False,
|
|
336
|
+
method="sigmoid",
|
|
337
|
+
)
|
|
338
|
+
# see custom stopgap solution defined above
|
|
339
|
+
_prefit_CalibratedClassifierCV_fit(self.clf_prob, X, y)
|
|
340
|
+
else:
|
|
341
|
+
|
|
342
|
+
self.clf_prob = CalibratedClassifierCV(
|
|
343
|
+
clf_base,
|
|
344
|
+
ensemble=False,
|
|
345
|
+
cv="prefit",
|
|
346
|
+
method="sigmoid",
|
|
347
|
+
).fit(X, y)
|
|
348
|
+
|
|
349
|
+
def _save_attributes(self):
|
|
350
|
+
self.support_vectors_ = self._onedal_estimator.support_vectors_
|
|
351
|
+
self.n_features_in_ = self._onedal_estimator.n_features_in_
|
|
352
|
+
self.fit_status_ = 0
|
|
353
|
+
self.dual_coef_ = self._onedal_estimator.dual_coef_
|
|
354
|
+
self.shape_fit_ = self._onedal_estimator.class_weight_
|
|
355
|
+
self.classes_ = self._onedal_estimator.classes_
|
|
356
|
+
if isinstance(self, ClassifierMixin) or not sklearn_check_version("1.2"):
|
|
357
|
+
self.class_weight_ = self._onedal_estimator.class_weight_
|
|
358
|
+
self.support_ = self._onedal_estimator.support_
|
|
359
|
+
|
|
360
|
+
self._icept_ = self._onedal_estimator.intercept_
|
|
361
|
+
self._n_support = self._onedal_estimator._n_support
|
|
362
|
+
self._sparse = False
|
|
363
|
+
self._gamma = self._onedal_estimator._gamma
|
|
364
|
+
if self.probability:
|
|
365
|
+
length = int(len(self.classes_) * (len(self.classes_) - 1) / 2)
|
|
366
|
+
self._probA = np.zeros(length)
|
|
367
|
+
self._probB = np.zeros(length)
|
|
368
|
+
else:
|
|
369
|
+
self._probA = np.empty(0)
|
|
370
|
+
self._probB = np.empty(0)
|
|
371
|
+
|
|
372
|
+
self._dualcoef_ = self.dual_coef_
|
|
373
|
+
|
|
374
|
+
if sklearn_check_version("1.1"):
|
|
375
|
+
length = int(len(self.classes_) * (len(self.classes_) - 1) / 2)
|
|
376
|
+
self.n_iter_ = np.full((length,), self._onedal_estimator.n_iter_)
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
class BaseSVR(BaseSVM):
|
|
380
|
+
def _save_attributes(self):
|
|
381
|
+
self.support_vectors_ = self._onedal_estimator.support_vectors_
|
|
382
|
+
self.n_features_in_ = self._onedal_estimator.n_features_in_
|
|
383
|
+
self.fit_status_ = 0
|
|
384
|
+
self.dual_coef_ = self._onedal_estimator.dual_coef_
|
|
385
|
+
self.shape_fit_ = self._onedal_estimator.shape_fit_
|
|
386
|
+
self.support_ = self._onedal_estimator.support_
|
|
387
|
+
|
|
388
|
+
self._icept_ = self._onedal_estimator.intercept_
|
|
389
|
+
self._n_support = [self.support_vectors_.shape[0]]
|
|
390
|
+
self._sparse = False
|
|
391
|
+
self._gamma = self._onedal_estimator._gamma
|
|
392
|
+
self._probA = None
|
|
393
|
+
self._probB = None
|
|
394
|
+
|
|
395
|
+
if sklearn_check_version("1.1"):
|
|
396
|
+
self.n_iter_ = self._onedal_estimator.n_iter_
|
|
397
|
+
|
|
398
|
+
self._dualcoef_ = self.dual_coef_
|
|
399
|
+
|
|
400
|
+
def _onedal_score(self, X, y, sample_weight=None, queue=None):
|
|
401
|
+
return r2_score(
|
|
402
|
+
y, self._onedal_predict(X, queue=queue), sample_weight=sample_weight
|
|
403
|
+
)
|
|
@@ -0,0 +1,278 @@
|
|
|
1
|
+
# ==============================================================================
|
|
2
|
+
# Copyright 2021 Intel Corporation
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
# ==============================================================================
|
|
16
|
+
|
|
17
|
+
from functools import wraps
|
|
18
|
+
|
|
19
|
+
import numpy as np
|
|
20
|
+
from sklearn.exceptions import NotFittedError
|
|
21
|
+
from sklearn.metrics import accuracy_score
|
|
22
|
+
from sklearn.svm import NuSVC as _sklearn_NuSVC
|
|
23
|
+
from sklearn.utils.metaestimators import available_if
|
|
24
|
+
from sklearn.utils.validation import (
|
|
25
|
+
_deprecate_positional_args,
|
|
26
|
+
check_array,
|
|
27
|
+
check_is_fitted,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
from daal4py.sklearn._n_jobs_support import control_n_jobs
|
|
31
|
+
from daal4py.sklearn._utils import sklearn_check_version
|
|
32
|
+
from onedal.svm import NuSVC as onedal_NuSVC
|
|
33
|
+
|
|
34
|
+
from .._device_offload import dispatch, wrap_output_data
|
|
35
|
+
from ..utils._array_api import get_namespace
|
|
36
|
+
from ..utils.validation import validate_data
|
|
37
|
+
from ._common import BaseSVC
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
@control_n_jobs(
|
|
41
|
+
decorated_methods=["fit", "predict", "_predict_proba", "decision_function", "score"]
|
|
42
|
+
)
|
|
43
|
+
class NuSVC(BaseSVC, _sklearn_NuSVC):
|
|
44
|
+
__doc__ = _sklearn_NuSVC.__doc__
|
|
45
|
+
|
|
46
|
+
if sklearn_check_version("1.2"):
|
|
47
|
+
_parameter_constraints: dict = {**_sklearn_NuSVC._parameter_constraints}
|
|
48
|
+
|
|
49
|
+
@_deprecate_positional_args
|
|
50
|
+
def __init__(
|
|
51
|
+
self,
|
|
52
|
+
*,
|
|
53
|
+
nu=0.5,
|
|
54
|
+
kernel="rbf",
|
|
55
|
+
degree=3,
|
|
56
|
+
gamma="scale",
|
|
57
|
+
coef0=0.0,
|
|
58
|
+
shrinking=True,
|
|
59
|
+
probability=False,
|
|
60
|
+
tol=1e-3,
|
|
61
|
+
cache_size=200,
|
|
62
|
+
class_weight=None,
|
|
63
|
+
verbose=False,
|
|
64
|
+
max_iter=-1,
|
|
65
|
+
decision_function_shape="ovr",
|
|
66
|
+
break_ties=False,
|
|
67
|
+
random_state=None,
|
|
68
|
+
):
|
|
69
|
+
super().__init__(
|
|
70
|
+
nu=nu,
|
|
71
|
+
kernel=kernel,
|
|
72
|
+
degree=degree,
|
|
73
|
+
gamma=gamma,
|
|
74
|
+
coef0=coef0,
|
|
75
|
+
shrinking=shrinking,
|
|
76
|
+
probability=probability,
|
|
77
|
+
tol=tol,
|
|
78
|
+
cache_size=cache_size,
|
|
79
|
+
class_weight=class_weight,
|
|
80
|
+
verbose=verbose,
|
|
81
|
+
max_iter=max_iter,
|
|
82
|
+
decision_function_shape=decision_function_shape,
|
|
83
|
+
break_ties=break_ties,
|
|
84
|
+
random_state=random_state,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
def fit(self, X, y, sample_weight=None):
|
|
88
|
+
if sklearn_check_version("1.2"):
|
|
89
|
+
self._validate_params()
|
|
90
|
+
elif self.nu <= 0 or self.nu > 1:
|
|
91
|
+
# else if added to correct issues with
|
|
92
|
+
# sklearn tests:
|
|
93
|
+
# svm/tests/test_sparse.py::test_error
|
|
94
|
+
# svm/tests/test_svm.py::test_bad_input
|
|
95
|
+
# for sklearn versions < 1.2 (i.e. without
|
|
96
|
+
# validate_params parameter checking)
|
|
97
|
+
# Without this, a segmentation fault with
|
|
98
|
+
# Windows fatal exception: access violation
|
|
99
|
+
# occurs
|
|
100
|
+
raise ValueError("nu <= 0 or nu > 1")
|
|
101
|
+
dispatch(
|
|
102
|
+
self,
|
|
103
|
+
"fit",
|
|
104
|
+
{
|
|
105
|
+
"onedal": self.__class__._onedal_fit,
|
|
106
|
+
"sklearn": _sklearn_NuSVC.fit,
|
|
107
|
+
},
|
|
108
|
+
X,
|
|
109
|
+
y,
|
|
110
|
+
sample_weight=sample_weight,
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
return self
|
|
114
|
+
|
|
115
|
+
@wrap_output_data
|
|
116
|
+
def predict(self, X):
|
|
117
|
+
check_is_fitted(self)
|
|
118
|
+
return dispatch(
|
|
119
|
+
self,
|
|
120
|
+
"predict",
|
|
121
|
+
{
|
|
122
|
+
"onedal": self.__class__._onedal_predict,
|
|
123
|
+
"sklearn": _sklearn_NuSVC.predict,
|
|
124
|
+
},
|
|
125
|
+
X,
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
@wrap_output_data
|
|
129
|
+
def score(self, X, y, sample_weight=None):
|
|
130
|
+
check_is_fitted(self)
|
|
131
|
+
return dispatch(
|
|
132
|
+
self,
|
|
133
|
+
"score",
|
|
134
|
+
{
|
|
135
|
+
"onedal": self.__class__._onedal_score,
|
|
136
|
+
"sklearn": _sklearn_NuSVC.score,
|
|
137
|
+
},
|
|
138
|
+
X,
|
|
139
|
+
y,
|
|
140
|
+
sample_weight=sample_weight,
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
@available_if(_sklearn_NuSVC._check_proba)
|
|
144
|
+
@wraps(_sklearn_NuSVC.predict_proba, assigned=["__doc__"])
|
|
145
|
+
def predict_proba(self, X):
|
|
146
|
+
check_is_fitted(self)
|
|
147
|
+
return self._predict_proba(X)
|
|
148
|
+
|
|
149
|
+
@available_if(_sklearn_NuSVC._check_proba)
|
|
150
|
+
@wraps(_sklearn_NuSVC.predict_log_proba, assigned=["__doc__"])
|
|
151
|
+
def predict_log_proba(self, X):
|
|
152
|
+
xp, _ = get_namespace(X)
|
|
153
|
+
|
|
154
|
+
return xp.log(self.predict_proba(X))
|
|
155
|
+
|
|
156
|
+
@wrap_output_data
|
|
157
|
+
def _predict_proba(self, X):
|
|
158
|
+
return dispatch(
|
|
159
|
+
self,
|
|
160
|
+
"predict_proba",
|
|
161
|
+
{
|
|
162
|
+
"onedal": self.__class__._onedal_predict_proba,
|
|
163
|
+
"sklearn": _sklearn_NuSVC.predict_proba,
|
|
164
|
+
},
|
|
165
|
+
X,
|
|
166
|
+
)
|
|
167
|
+
|
|
168
|
+
@wrap_output_data
|
|
169
|
+
def decision_function(self, X):
|
|
170
|
+
check_is_fitted(self)
|
|
171
|
+
return dispatch(
|
|
172
|
+
self,
|
|
173
|
+
"decision_function",
|
|
174
|
+
{
|
|
175
|
+
"onedal": self.__class__._onedal_decision_function,
|
|
176
|
+
"sklearn": _sklearn_NuSVC.decision_function,
|
|
177
|
+
},
|
|
178
|
+
X,
|
|
179
|
+
)
|
|
180
|
+
|
|
181
|
+
decision_function.__doc__ = _sklearn_NuSVC.decision_function.__doc__
|
|
182
|
+
|
|
183
|
+
def _get_sample_weight(self, X, y, sample_weight=None):
|
|
184
|
+
sample_weight = super()._get_sample_weight(X, y, sample_weight)
|
|
185
|
+
if sample_weight is None:
|
|
186
|
+
return sample_weight
|
|
187
|
+
|
|
188
|
+
weight_per_class = [
|
|
189
|
+
np.sum(sample_weight[y == class_label]) for class_label in np.unique(y)
|
|
190
|
+
]
|
|
191
|
+
|
|
192
|
+
for i in range(len(weight_per_class)):
|
|
193
|
+
for j in range(i + 1, len(weight_per_class)):
|
|
194
|
+
if self.nu * (weight_per_class[i] + weight_per_class[j]) / 2 > min(
|
|
195
|
+
weight_per_class[i], weight_per_class[j]
|
|
196
|
+
):
|
|
197
|
+
raise ValueError("specified nu is infeasible")
|
|
198
|
+
|
|
199
|
+
return sample_weight
|
|
200
|
+
|
|
201
|
+
def _onedal_fit(self, X, y, sample_weight=None, queue=None):
|
|
202
|
+
X, _, weights = self._onedal_fit_checks(X, y, sample_weight)
|
|
203
|
+
onedal_params = {
|
|
204
|
+
"nu": self.nu,
|
|
205
|
+
"kernel": self.kernel,
|
|
206
|
+
"degree": self.degree,
|
|
207
|
+
"gamma": self._compute_gamma_sigma(X),
|
|
208
|
+
"coef0": self.coef0,
|
|
209
|
+
"tol": self.tol,
|
|
210
|
+
"shrinking": self.shrinking,
|
|
211
|
+
"cache_size": self.cache_size,
|
|
212
|
+
"max_iter": self.max_iter,
|
|
213
|
+
"class_weight": self.class_weight,
|
|
214
|
+
"break_ties": self.break_ties,
|
|
215
|
+
"decision_function_shape": self.decision_function_shape,
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
self._onedal_estimator = onedal_NuSVC(**onedal_params)
|
|
219
|
+
self._onedal_estimator.fit(X, y, weights, queue=queue)
|
|
220
|
+
|
|
221
|
+
if self.probability:
|
|
222
|
+
self._fit_proba(
|
|
223
|
+
X,
|
|
224
|
+
y,
|
|
225
|
+
sample_weight=sample_weight,
|
|
226
|
+
queue=queue,
|
|
227
|
+
)
|
|
228
|
+
|
|
229
|
+
self._save_attributes()
|
|
230
|
+
|
|
231
|
+
def _onedal_predict(self, X, queue=None):
|
|
232
|
+
validate_data(
|
|
233
|
+
self,
|
|
234
|
+
X,
|
|
235
|
+
dtype=[np.float64, np.float32],
|
|
236
|
+
ensure_all_finite=False,
|
|
237
|
+
ensure_2d=False,
|
|
238
|
+
accept_sparse="csr",
|
|
239
|
+
reset=False,
|
|
240
|
+
)
|
|
241
|
+
|
|
242
|
+
return self._onedal_estimator.predict(X, queue=queue)
|
|
243
|
+
|
|
244
|
+
def _onedal_predict_proba(self, X, queue=None):
|
|
245
|
+
if getattr(self, "clf_prob", None) is None:
|
|
246
|
+
raise NotFittedError(
|
|
247
|
+
"predict_proba is not available when fitted with probability=False"
|
|
248
|
+
)
|
|
249
|
+
from .._config import config_context, get_config
|
|
250
|
+
|
|
251
|
+
# We use stock metaestimators below, so the only way
|
|
252
|
+
# to pass a queue is using config_context.
|
|
253
|
+
cfg = get_config()
|
|
254
|
+
cfg["target_offload"] = queue
|
|
255
|
+
with config_context(**cfg):
|
|
256
|
+
return self.clf_prob.predict_proba(X)
|
|
257
|
+
|
|
258
|
+
def _onedal_decision_function(self, X, queue=None):
|
|
259
|
+
validate_data(
|
|
260
|
+
self,
|
|
261
|
+
X,
|
|
262
|
+
dtype=[np.float64, np.float32],
|
|
263
|
+
ensure_all_finite=False,
|
|
264
|
+
accept_sparse="csr",
|
|
265
|
+
reset=False,
|
|
266
|
+
)
|
|
267
|
+
|
|
268
|
+
return self._onedal_estimator.decision_function(X, queue=queue)
|
|
269
|
+
|
|
270
|
+
def _onedal_score(self, X, y, sample_weight=None, queue=None):
|
|
271
|
+
return accuracy_score(
|
|
272
|
+
y, self._onedal_predict(X, queue=queue), sample_weight=sample_weight
|
|
273
|
+
)
|
|
274
|
+
|
|
275
|
+
fit.__doc__ = _sklearn_NuSVC.fit.__doc__
|
|
276
|
+
predict.__doc__ = _sklearn_NuSVC.predict.__doc__
|
|
277
|
+
decision_function.__doc__ = _sklearn_NuSVC.decision_function.__doc__
|
|
278
|
+
score.__doc__ = _sklearn_NuSVC.score.__doc__
|