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,20 @@
|
|
|
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 daal4py.sklearn.model_selection import train_test_split
|
|
18
|
+
from onedal._device_offload import support_input_format
|
|
19
|
+
|
|
20
|
+
train_test_split = support_input_format(train_test_split)
|
|
@@ -0,0 +1,34 @@
|
|
|
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 numpy as np
|
|
18
|
+
from numpy.testing import assert_allclose
|
|
19
|
+
|
|
20
|
+
|
|
21
|
+
# TODO:
|
|
22
|
+
# add pytest params for checking different dataframe inputs/outputs.
|
|
23
|
+
def test_sklearnex_import_train_test_split():
|
|
24
|
+
from sklearnex.model_selection import train_test_split
|
|
25
|
+
|
|
26
|
+
X = np.arange(100).reshape((10, 10))
|
|
27
|
+
y = np.arange(10)
|
|
28
|
+
|
|
29
|
+
split = train_test_split(X, y, test_size=None, train_size=0.5)
|
|
30
|
+
X_train, X_test, y_train, y_test = split
|
|
31
|
+
assert len(y_test) == len(y_train)
|
|
32
|
+
|
|
33
|
+
assert_allclose(X_train[:, 0], y_train * 10)
|
|
34
|
+
assert_allclose(X_test[:, 0], y_test * 10)
|
|
@@ -0,0 +1,27 @@
|
|
|
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 ._lof import LocalOutlierFactor
|
|
18
|
+
from .knn_classification import KNeighborsClassifier
|
|
19
|
+
from .knn_regression import KNeighborsRegressor
|
|
20
|
+
from .knn_unsupervised import NearestNeighbors
|
|
21
|
+
|
|
22
|
+
__all__ = [
|
|
23
|
+
"KNeighborsClassifier",
|
|
24
|
+
"KNeighborsRegressor",
|
|
25
|
+
"LocalOutlierFactor",
|
|
26
|
+
"NearestNeighbors",
|
|
27
|
+
]
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
# ===============================================================================
|
|
2
|
+
# Copyright 2024 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 functools import wraps
|
|
19
|
+
|
|
20
|
+
import numpy as np
|
|
21
|
+
from sklearn.neighbors import LocalOutlierFactor as _sklearn_LocalOutlierFactor
|
|
22
|
+
from sklearn.utils.metaestimators import available_if
|
|
23
|
+
from sklearn.utils.validation import check_is_fitted
|
|
24
|
+
|
|
25
|
+
from daal4py.sklearn._n_jobs_support import control_n_jobs
|
|
26
|
+
from daal4py.sklearn._utils import sklearn_check_version
|
|
27
|
+
from sklearnex._device_offload import dispatch, wrap_output_data
|
|
28
|
+
from sklearnex.neighbors.common import KNeighborsDispatchingBase
|
|
29
|
+
from sklearnex.neighbors.knn_unsupervised import NearestNeighbors
|
|
30
|
+
|
|
31
|
+
from ..utils._array_api import get_namespace
|
|
32
|
+
from ..utils.validation import check_feature_names
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
@control_n_jobs(decorated_methods=["fit", "kneighbors", "_kneighbors"])
|
|
36
|
+
class LocalOutlierFactor(KNeighborsDispatchingBase, _sklearn_LocalOutlierFactor):
|
|
37
|
+
__doc__ = (
|
|
38
|
+
_sklearn_LocalOutlierFactor.__doc__
|
|
39
|
+
+ "\n NOTE: When X=None, methods kneighbors, kneighbors_graph, and predict will"
|
|
40
|
+
+ "\n only output numpy arrays. In that case, the only way to offload to gpu"
|
|
41
|
+
+ "\n is to use a global queue (e.g. using config_context)"
|
|
42
|
+
)
|
|
43
|
+
if sklearn_check_version("1.2"):
|
|
44
|
+
_parameter_constraints: dict = {
|
|
45
|
+
**_sklearn_LocalOutlierFactor._parameter_constraints
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
# Only certain methods should be taken from knn to prevent code
|
|
49
|
+
# duplication. Inheriting would yield a complicated inheritance
|
|
50
|
+
# structure and violate the sklearn inheritance path.
|
|
51
|
+
_save_attributes = NearestNeighbors._save_attributes
|
|
52
|
+
_onedal_knn_fit = NearestNeighbors._onedal_fit
|
|
53
|
+
_onedal_kneighbors = NearestNeighbors._onedal_kneighbors
|
|
54
|
+
|
|
55
|
+
def _onedal_fit(self, X, y, queue=None):
|
|
56
|
+
if sklearn_check_version("1.2"):
|
|
57
|
+
self._validate_params()
|
|
58
|
+
|
|
59
|
+
self._onedal_knn_fit(X, y, queue=queue)
|
|
60
|
+
|
|
61
|
+
if self.contamination != "auto":
|
|
62
|
+
if not (0.0 < self.contamination <= 0.5):
|
|
63
|
+
raise ValueError(
|
|
64
|
+
"contamination must be in (0, 0.5], " "got: %f" % self.contamination
|
|
65
|
+
)
|
|
66
|
+
|
|
67
|
+
n_samples = self.n_samples_fit_
|
|
68
|
+
|
|
69
|
+
if self.n_neighbors > n_samples:
|
|
70
|
+
warnings.warn(
|
|
71
|
+
"n_neighbors (%s) is greater than the "
|
|
72
|
+
"total number of samples (%s). n_neighbors "
|
|
73
|
+
"will be set to (n_samples - 1) for estimation."
|
|
74
|
+
% (self.n_neighbors, n_samples)
|
|
75
|
+
)
|
|
76
|
+
self.n_neighbors_ = max(1, min(self.n_neighbors, n_samples - 1))
|
|
77
|
+
|
|
78
|
+
(
|
|
79
|
+
self._distances_fit_X_,
|
|
80
|
+
_neighbors_indices_fit_X_,
|
|
81
|
+
) = self._onedal_kneighbors(n_neighbors=self.n_neighbors_, queue=queue)
|
|
82
|
+
|
|
83
|
+
# Sklearn includes a check for float32 at this point which may not be
|
|
84
|
+
# necessary for onedal
|
|
85
|
+
|
|
86
|
+
self._lrd = self._local_reachability_density(
|
|
87
|
+
self._distances_fit_X_, _neighbors_indices_fit_X_
|
|
88
|
+
)
|
|
89
|
+
|
|
90
|
+
# Compute lof score over training samples to define offset_:
|
|
91
|
+
lrd_ratios_array = self._lrd[_neighbors_indices_fit_X_] / self._lrd[:, np.newaxis]
|
|
92
|
+
|
|
93
|
+
self.negative_outlier_factor_ = -np.mean(lrd_ratios_array, axis=1)
|
|
94
|
+
|
|
95
|
+
if self.contamination == "auto":
|
|
96
|
+
# inliers score around -1 (the higher, the less abnormal).
|
|
97
|
+
self.offset_ = -1.5
|
|
98
|
+
else:
|
|
99
|
+
self.offset_ = np.percentile(
|
|
100
|
+
self.negative_outlier_factor_, 100.0 * self.contamination
|
|
101
|
+
)
|
|
102
|
+
|
|
103
|
+
# adoption of warning for data with duplicated samples from
|
|
104
|
+
# https://github.com/scikit-learn/scikit-learn/pull/28773
|
|
105
|
+
if sklearn_check_version("1.6"):
|
|
106
|
+
if np.min(self.negative_outlier_factor_) < -1e7 and not self.novelty:
|
|
107
|
+
warnings.warn(
|
|
108
|
+
"Duplicate values are leading to incorrect results. "
|
|
109
|
+
"Increase the number of neighbors for more accurate results."
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
return self
|
|
113
|
+
|
|
114
|
+
def fit(self, X, y=None):
|
|
115
|
+
result = dispatch(
|
|
116
|
+
self,
|
|
117
|
+
"fit",
|
|
118
|
+
{
|
|
119
|
+
"onedal": self.__class__._onedal_fit,
|
|
120
|
+
"sklearn": _sklearn_LocalOutlierFactor.fit,
|
|
121
|
+
},
|
|
122
|
+
X,
|
|
123
|
+
None,
|
|
124
|
+
)
|
|
125
|
+
return result
|
|
126
|
+
|
|
127
|
+
def _predict(self, X=None):
|
|
128
|
+
check_is_fitted(self)
|
|
129
|
+
|
|
130
|
+
if X is not None:
|
|
131
|
+
xp, _ = get_namespace(X)
|
|
132
|
+
output = self.decision_function(X) < 0
|
|
133
|
+
is_inlier = xp.ones_like(output, dtype=int)
|
|
134
|
+
is_inlier[output] = -1
|
|
135
|
+
else:
|
|
136
|
+
is_inlier = np.ones(self.n_samples_fit_, dtype=int)
|
|
137
|
+
is_inlier[self.negative_outlier_factor_ < self.offset_] = -1
|
|
138
|
+
|
|
139
|
+
return is_inlier
|
|
140
|
+
|
|
141
|
+
# This had to be done because predict loses the queue when no
|
|
142
|
+
# argument is given and it is a dpctl tensor or dpnp array.
|
|
143
|
+
# This would cause issues in fit_predict. Also, available_if
|
|
144
|
+
# is hard to unwrap, and this is the most straightforward way.
|
|
145
|
+
@available_if(_sklearn_LocalOutlierFactor._check_novelty_fit_predict)
|
|
146
|
+
@wraps(_sklearn_LocalOutlierFactor.fit_predict, assigned=["__doc__"])
|
|
147
|
+
@wrap_output_data
|
|
148
|
+
def fit_predict(self, X, y=None):
|
|
149
|
+
return self.fit(X)._predict()
|
|
150
|
+
|
|
151
|
+
def _kneighbors(self, X=None, n_neighbors=None, return_distance=True):
|
|
152
|
+
check_is_fitted(self)
|
|
153
|
+
if X is not None:
|
|
154
|
+
check_feature_names(self, X, reset=False)
|
|
155
|
+
return dispatch(
|
|
156
|
+
self,
|
|
157
|
+
"kneighbors",
|
|
158
|
+
{
|
|
159
|
+
"onedal": self.__class__._onedal_kneighbors,
|
|
160
|
+
"sklearn": _sklearn_LocalOutlierFactor.kneighbors,
|
|
161
|
+
},
|
|
162
|
+
X,
|
|
163
|
+
n_neighbors=n_neighbors,
|
|
164
|
+
return_distance=return_distance,
|
|
165
|
+
)
|
|
166
|
+
|
|
167
|
+
kneighbors = wrap_output_data(_kneighbors)
|
|
168
|
+
|
|
169
|
+
@available_if(_sklearn_LocalOutlierFactor._check_novelty_score_samples)
|
|
170
|
+
@wraps(_sklearn_LocalOutlierFactor.score_samples, assigned=["__doc__"])
|
|
171
|
+
@wrap_output_data
|
|
172
|
+
def score_samples(self, X):
|
|
173
|
+
check_is_fitted(self)
|
|
174
|
+
|
|
175
|
+
distances_X, neighbors_indices_X = self._kneighbors(
|
|
176
|
+
X, n_neighbors=self.n_neighbors_
|
|
177
|
+
)
|
|
178
|
+
|
|
179
|
+
X_lrd = self._local_reachability_density(
|
|
180
|
+
distances_X,
|
|
181
|
+
neighbors_indices_X,
|
|
182
|
+
)
|
|
183
|
+
|
|
184
|
+
lrd_ratios_array = self._lrd[neighbors_indices_X] / X_lrd[:, np.newaxis]
|
|
185
|
+
|
|
186
|
+
return -np.mean(lrd_ratios_array, axis=1)
|
|
187
|
+
|
|
188
|
+
fit.__doc__ = _sklearn_LocalOutlierFactor.fit.__doc__
|
|
189
|
+
kneighbors.__doc__ = _sklearn_LocalOutlierFactor.kneighbors.__doc__
|
|
@@ -0,0 +1,313 @@
|
|
|
1
|
+
# ==============================================================================
|
|
2
|
+
# Copyright 2023 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
|
+
|
|
19
|
+
import numpy as np
|
|
20
|
+
from scipy import sparse as sp
|
|
21
|
+
from sklearn.neighbors._ball_tree import BallTree
|
|
22
|
+
from sklearn.neighbors._base import VALID_METRICS, KNeighborsMixin
|
|
23
|
+
from sklearn.neighbors._base import NeighborsBase as _sklearn_NeighborsBase
|
|
24
|
+
from sklearn.neighbors._kd_tree import KDTree
|
|
25
|
+
from sklearn.utils.validation import check_is_fitted
|
|
26
|
+
|
|
27
|
+
from daal4py.sklearn._utils import sklearn_check_version
|
|
28
|
+
from onedal._device_offload import _transfer_to_host
|
|
29
|
+
from onedal.utils.validation import _check_array, _num_features, _num_samples
|
|
30
|
+
|
|
31
|
+
from .._utils import PatchingConditionsChain
|
|
32
|
+
from ..base import oneDALEstimator
|
|
33
|
+
from ..utils._array_api import get_namespace
|
|
34
|
+
from ..utils.validation import check_feature_names
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class KNeighborsDispatchingBase(oneDALEstimator):
|
|
38
|
+
def _fit_validation(self, X, y=None):
|
|
39
|
+
if sklearn_check_version("1.2"):
|
|
40
|
+
self._validate_params()
|
|
41
|
+
check_feature_names(self, X, reset=True)
|
|
42
|
+
if self.metric_params is not None and "p" in self.metric_params:
|
|
43
|
+
if self.p is not None:
|
|
44
|
+
warnings.warn(
|
|
45
|
+
"Parameter p is found in metric_params. "
|
|
46
|
+
"The corresponding parameter from __init__ "
|
|
47
|
+
"is ignored.",
|
|
48
|
+
SyntaxWarning,
|
|
49
|
+
stacklevel=2,
|
|
50
|
+
)
|
|
51
|
+
self.effective_metric_params_ = self.metric_params.copy()
|
|
52
|
+
effective_p = self.metric_params["p"]
|
|
53
|
+
else:
|
|
54
|
+
self.effective_metric_params_ = {}
|
|
55
|
+
effective_p = self.p
|
|
56
|
+
|
|
57
|
+
self.effective_metric_params_["p"] = effective_p
|
|
58
|
+
self.effective_metric_ = self.metric
|
|
59
|
+
# For minkowski distance, use more efficient methods where available
|
|
60
|
+
if self.metric == "minkowski":
|
|
61
|
+
p = self.effective_metric_params_["p"]
|
|
62
|
+
if p == 1:
|
|
63
|
+
self.effective_metric_ = "manhattan"
|
|
64
|
+
elif p == 2:
|
|
65
|
+
self.effective_metric_ = "euclidean"
|
|
66
|
+
elif p == np.inf:
|
|
67
|
+
self.effective_metric_ = "chebyshev"
|
|
68
|
+
|
|
69
|
+
if not isinstance(X, (KDTree, BallTree, _sklearn_NeighborsBase)):
|
|
70
|
+
self._fit_X = _check_array(
|
|
71
|
+
X, dtype=[np.float64, np.float32], accept_sparse=True
|
|
72
|
+
)
|
|
73
|
+
self.n_samples_fit_ = _num_samples(self._fit_X)
|
|
74
|
+
self.n_features_in_ = _num_features(self._fit_X)
|
|
75
|
+
|
|
76
|
+
if self.algorithm == "auto":
|
|
77
|
+
# A tree approach is better for small number of neighbors or small
|
|
78
|
+
# number of features, with KDTree generally faster when available
|
|
79
|
+
is_n_neighbors_valid_for_brute = (
|
|
80
|
+
self.n_neighbors is not None
|
|
81
|
+
and self.n_neighbors >= self._fit_X.shape[0] // 2
|
|
82
|
+
)
|
|
83
|
+
if self._fit_X.shape[1] > 15 or is_n_neighbors_valid_for_brute:
|
|
84
|
+
self._fit_method = "brute"
|
|
85
|
+
else:
|
|
86
|
+
if self.effective_metric_ in VALID_METRICS["kd_tree"]:
|
|
87
|
+
self._fit_method = "kd_tree"
|
|
88
|
+
elif (
|
|
89
|
+
callable(self.effective_metric_)
|
|
90
|
+
or self.effective_metric_ in VALID_METRICS["ball_tree"]
|
|
91
|
+
):
|
|
92
|
+
self._fit_method = "ball_tree"
|
|
93
|
+
else:
|
|
94
|
+
self._fit_method = "brute"
|
|
95
|
+
else:
|
|
96
|
+
self._fit_method = self.algorithm
|
|
97
|
+
|
|
98
|
+
if hasattr(self, "_onedal_estimator"):
|
|
99
|
+
delattr(self, "_onedal_estimator")
|
|
100
|
+
# To cover test case when we pass patched
|
|
101
|
+
# estimator as an input for other estimator
|
|
102
|
+
if isinstance(X, _sklearn_NeighborsBase):
|
|
103
|
+
self._fit_X = X._fit_X
|
|
104
|
+
self._tree = X._tree
|
|
105
|
+
self._fit_method = X._fit_method
|
|
106
|
+
self.n_samples_fit_ = X.n_samples_fit_
|
|
107
|
+
self.n_features_in_ = X.n_features_in_
|
|
108
|
+
if hasattr(X, "_onedal_estimator"):
|
|
109
|
+
self.effective_metric_params_.pop("p")
|
|
110
|
+
if self._fit_method == "ball_tree":
|
|
111
|
+
X._tree = BallTree(
|
|
112
|
+
X._fit_X,
|
|
113
|
+
self.leaf_size,
|
|
114
|
+
metric=self.effective_metric_,
|
|
115
|
+
**self.effective_metric_params_,
|
|
116
|
+
)
|
|
117
|
+
elif self._fit_method == "kd_tree":
|
|
118
|
+
X._tree = KDTree(
|
|
119
|
+
X._fit_X,
|
|
120
|
+
self.leaf_size,
|
|
121
|
+
metric=self.effective_metric_,
|
|
122
|
+
**self.effective_metric_params_,
|
|
123
|
+
)
|
|
124
|
+
elif self._fit_method == "brute":
|
|
125
|
+
X._tree = None
|
|
126
|
+
else:
|
|
127
|
+
raise ValueError("algorithm = '%s' not recognized" % self.algorithm)
|
|
128
|
+
|
|
129
|
+
elif isinstance(X, BallTree):
|
|
130
|
+
self._fit_X = X.data
|
|
131
|
+
self._tree = X
|
|
132
|
+
self._fit_method = "ball_tree"
|
|
133
|
+
self.n_samples_fit_ = X.data.shape[0]
|
|
134
|
+
self.n_features_in_ = X.data.shape[1]
|
|
135
|
+
|
|
136
|
+
elif isinstance(X, KDTree):
|
|
137
|
+
self._fit_X = X.data
|
|
138
|
+
self._tree = X
|
|
139
|
+
self._fit_method = "kd_tree"
|
|
140
|
+
self.n_samples_fit_ = X.data.shape[0]
|
|
141
|
+
self.n_features_in_ = X.data.shape[1]
|
|
142
|
+
|
|
143
|
+
def _onedal_supported(self, device, method_name, *data):
|
|
144
|
+
if method_name == "fit":
|
|
145
|
+
self._fit_validation(data[0], data[1])
|
|
146
|
+
|
|
147
|
+
class_name = self.__class__.__name__
|
|
148
|
+
is_classifier = "Classifier" in class_name
|
|
149
|
+
is_regressor = "Regressor" in class_name
|
|
150
|
+
is_unsupervised = not (is_classifier or is_regressor)
|
|
151
|
+
patching_status = PatchingConditionsChain(
|
|
152
|
+
f"sklearn.neighbors.{class_name}.{method_name}"
|
|
153
|
+
)
|
|
154
|
+
if not patching_status.and_condition(
|
|
155
|
+
"radius" not in method_name, "RadiusNeighbors not implemented in sklearnex"
|
|
156
|
+
):
|
|
157
|
+
return patching_status
|
|
158
|
+
|
|
159
|
+
if not patching_status.and_condition(
|
|
160
|
+
not isinstance(data[0], (KDTree, BallTree, _sklearn_NeighborsBase)),
|
|
161
|
+
f"Input type {type(data[0])} is not supported.",
|
|
162
|
+
):
|
|
163
|
+
return patching_status
|
|
164
|
+
|
|
165
|
+
if self._fit_method in ["auto", "ball_tree"]:
|
|
166
|
+
condition = (
|
|
167
|
+
self.n_neighbors is not None
|
|
168
|
+
and self.n_neighbors >= self.n_samples_fit_ // 2
|
|
169
|
+
)
|
|
170
|
+
if self.n_features_in_ > 15 or condition:
|
|
171
|
+
result_method = "brute"
|
|
172
|
+
else:
|
|
173
|
+
if self.effective_metric_ in ["euclidean"]:
|
|
174
|
+
result_method = "kd_tree"
|
|
175
|
+
else:
|
|
176
|
+
result_method = "brute"
|
|
177
|
+
else:
|
|
178
|
+
result_method = self._fit_method
|
|
179
|
+
|
|
180
|
+
p_less_than_one = (
|
|
181
|
+
"p" in self.effective_metric_params_.keys()
|
|
182
|
+
and self.effective_metric_params_["p"] < 1
|
|
183
|
+
)
|
|
184
|
+
if not patching_status.and_condition(
|
|
185
|
+
not p_less_than_one, '"p" metric parameter is less than 1'
|
|
186
|
+
):
|
|
187
|
+
return patching_status
|
|
188
|
+
|
|
189
|
+
if not patching_status.and_condition(
|
|
190
|
+
not sp.issparse(data[0]), "Sparse input is not supported."
|
|
191
|
+
):
|
|
192
|
+
return patching_status
|
|
193
|
+
|
|
194
|
+
if not is_unsupervised:
|
|
195
|
+
is_valid_weights = self.weights in ["uniform", "distance"]
|
|
196
|
+
if is_classifier:
|
|
197
|
+
class_count = 1
|
|
198
|
+
is_single_output = False
|
|
199
|
+
y = None
|
|
200
|
+
# To check multioutput, might be overhead
|
|
201
|
+
if len(data) > 1:
|
|
202
|
+
y = np.asarray(data[1])
|
|
203
|
+
if is_classifier:
|
|
204
|
+
class_count = len(np.unique(y))
|
|
205
|
+
if hasattr(self, "_onedal_estimator"):
|
|
206
|
+
y = self._onedal_estimator._y
|
|
207
|
+
if y is not None and hasattr(y, "ndim") and hasattr(y, "shape"):
|
|
208
|
+
is_single_output = y.ndim == 1 or y.ndim == 2 and y.shape[1] == 1
|
|
209
|
+
|
|
210
|
+
# TODO: add native support for these metric names
|
|
211
|
+
metrics_map = {"manhattan": ["l1", "cityblock"], "euclidean": ["l2"]}
|
|
212
|
+
for origin, aliases in metrics_map.items():
|
|
213
|
+
if self.effective_metric_ in aliases:
|
|
214
|
+
self.effective_metric_ = origin
|
|
215
|
+
break
|
|
216
|
+
if self.effective_metric_ == "manhattan":
|
|
217
|
+
self.effective_metric_params_["p"] = 1
|
|
218
|
+
elif self.effective_metric_ == "euclidean":
|
|
219
|
+
self.effective_metric_params_["p"] = 2
|
|
220
|
+
|
|
221
|
+
onedal_brute_metrics = [
|
|
222
|
+
"manhattan",
|
|
223
|
+
"minkowski",
|
|
224
|
+
"euclidean",
|
|
225
|
+
"chebyshev",
|
|
226
|
+
"cosine",
|
|
227
|
+
]
|
|
228
|
+
onedal_kdtree_metrics = ["euclidean"]
|
|
229
|
+
is_valid_for_brute = (
|
|
230
|
+
result_method == "brute" and self.effective_metric_ in onedal_brute_metrics
|
|
231
|
+
)
|
|
232
|
+
is_valid_for_kd_tree = (
|
|
233
|
+
result_method == "kd_tree" and self.effective_metric_ in onedal_kdtree_metrics
|
|
234
|
+
)
|
|
235
|
+
if result_method == "kd_tree":
|
|
236
|
+
if not patching_status.and_condition(
|
|
237
|
+
device != "gpu", '"kd_tree" method is not supported on GPU.'
|
|
238
|
+
):
|
|
239
|
+
return patching_status
|
|
240
|
+
|
|
241
|
+
if not patching_status.and_condition(
|
|
242
|
+
is_valid_for_kd_tree or is_valid_for_brute,
|
|
243
|
+
f"{result_method} with {self.effective_metric_} metric is not supported.",
|
|
244
|
+
):
|
|
245
|
+
return patching_status
|
|
246
|
+
if not is_unsupervised:
|
|
247
|
+
if not patching_status.and_conditions(
|
|
248
|
+
[
|
|
249
|
+
(is_single_output, "Only single output is supported."),
|
|
250
|
+
(
|
|
251
|
+
is_valid_weights,
|
|
252
|
+
f'"{type(self.weights)}" weights type is not supported.',
|
|
253
|
+
),
|
|
254
|
+
]
|
|
255
|
+
):
|
|
256
|
+
return patching_status
|
|
257
|
+
if method_name == "fit":
|
|
258
|
+
if is_classifier:
|
|
259
|
+
patching_status.and_condition(
|
|
260
|
+
class_count >= 2, "One-class case is not supported."
|
|
261
|
+
)
|
|
262
|
+
return patching_status
|
|
263
|
+
if method_name in ["predict", "predict_proba", "kneighbors", "score"]:
|
|
264
|
+
patching_status.and_condition(
|
|
265
|
+
hasattr(self, "_onedal_estimator"), "oneDAL model was not trained."
|
|
266
|
+
)
|
|
267
|
+
return patching_status
|
|
268
|
+
raise RuntimeError(f"Unknown method {method_name} in {class_name}")
|
|
269
|
+
|
|
270
|
+
def _onedal_gpu_supported(self, method_name, *data):
|
|
271
|
+
return self._onedal_supported("gpu", method_name, *data)
|
|
272
|
+
|
|
273
|
+
def _onedal_cpu_supported(self, method_name, *data):
|
|
274
|
+
return self._onedal_supported("cpu", method_name, *data)
|
|
275
|
+
|
|
276
|
+
def kneighbors_graph(self, X=None, n_neighbors=None, mode="connectivity"):
|
|
277
|
+
check_is_fitted(self)
|
|
278
|
+
if n_neighbors is None:
|
|
279
|
+
n_neighbors = self.n_neighbors
|
|
280
|
+
|
|
281
|
+
# check the input only in self.kneighbors
|
|
282
|
+
|
|
283
|
+
# construct CSR matrix representation of the k-NN graph
|
|
284
|
+
# requires moving data to host to construct the csr_matrix
|
|
285
|
+
if mode == "connectivity":
|
|
286
|
+
A_ind = self.kneighbors(X, n_neighbors, return_distance=False)
|
|
287
|
+
_, (A_ind,) = _transfer_to_host(A_ind)
|
|
288
|
+
n_queries = A_ind.shape[0]
|
|
289
|
+
A_data = np.ones(n_queries * n_neighbors)
|
|
290
|
+
|
|
291
|
+
elif mode == "distance":
|
|
292
|
+
A_data, A_ind = self.kneighbors(X, n_neighbors, return_distance=True)
|
|
293
|
+
_, (A_data, A_ind) = _transfer_to_host(A_data, A_ind)
|
|
294
|
+
A_data = np.reshape(A_data, (-1,))
|
|
295
|
+
|
|
296
|
+
else:
|
|
297
|
+
raise ValueError(
|
|
298
|
+
'Unsupported mode, must be one of "connectivity", '
|
|
299
|
+
f'or "distance" but got "{mode}" instead'
|
|
300
|
+
)
|
|
301
|
+
|
|
302
|
+
n_queries = A_ind.shape[0]
|
|
303
|
+
n_samples_fit = self.n_samples_fit_
|
|
304
|
+
n_nonzero = n_queries * n_neighbors
|
|
305
|
+
A_indptr = np.arange(0, n_nonzero + 1, n_neighbors)
|
|
306
|
+
|
|
307
|
+
kneighbors_graph = sp.csr_matrix(
|
|
308
|
+
(A_data, np.reshape(A_ind, (-1,)), A_indptr), shape=(n_queries, n_samples_fit)
|
|
309
|
+
)
|
|
310
|
+
|
|
311
|
+
return kneighbors_graph
|
|
312
|
+
|
|
313
|
+
kneighbors_graph.__doc__ = KNeighborsMixin.kneighbors_graph.__doc__
|