scikit-learn-intelex 2024.5.0__py310-none-win_amd64.whl → 2024.7.0__py310-none-win_amd64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of scikit-learn-intelex might be problematic. Click here for more details.
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/_config.py +3 -15
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/_device_offload.py +98 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/basic_statistics/basic_statistics.py +143 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/basic_statistics/tests/test_basic_statistics.py +251 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/basic_statistics/tests/test_incremental_basic_statistics.py +1 -1
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/cluster/dbscan.py +3 -1
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/cluster/k_means.py +8 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/cluster/tests/test_dbscan.py +8 -6
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/cluster/tests/test_kmeans.py +15 -3
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/conftest.py +11 -1
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/covariance/incremental_covariance.py +64 -13
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/covariance/tests/test_incremental_covariance.py +35 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/decomposition/pca.py +25 -1
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/decomposition/tests/test_pca.py +4 -2
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/dispatcher.py +109 -1
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/ensemble/_forest.py +121 -57
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/ensemble/tests/test_forest.py +7 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/glob/dispatcher.py +16 -2
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/linear_model/coordinate_descent.py +13 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/linear_model/incremental_linear.py +102 -25
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/linear_model/linear.py +25 -39
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/linear_model/logistic_regression.py +92 -74
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/linear_model/ridge.py +7 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/linear_model/tests/test_incremental_linear.py +10 -10
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/linear_model/tests/test_linear.py +30 -5
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/linear_model/tests/test_logreg.py +45 -3
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/manifold/t_sne.py +21 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/metrics/pairwise.py +5 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/metrics/ranking.py +3 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/model_selection/split.py +3 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/neighbors/_lof.py +9 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/neighbors/common.py +45 -1
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/neighbors/knn_classification.py +1 -20
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/neighbors/knn_regression.py +25 -20
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/neighbors/knn_unsupervised.py +31 -7
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/preview/__init__.py +1 -1
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/__init__.py +19 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/incremental_pca.py +228 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/tests/test_incremental_pca.py +266 -0
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/manifold/t_sne.py → scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/preview/linear_model/__init__.py +19 -17
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/preview/linear_model/ridge.py +419 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/preview/linear_model/tests/test_ridge.py +102 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/spmd/basic_statistics/tests/test_basic_statistics_spmd.py +107 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/tests/test_dbscan_spmd.py +97 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/spmd/cluster/tests/test_kmeans_spmd.py +172 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/spmd/covariance/tests/test_covariance_spmd.py +107 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/spmd/decomposition/tests/test_pca_spmd.py +128 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/spmd/ensemble/tests/test_forest_spmd.py +265 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/tests/test_linear_regression_spmd.py +145 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/spmd/linear_model/tests/test_logistic_regression_spmd.py +163 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/spmd/neighbors/tests/test_neighbors_spmd.py +288 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/svm/_common.py +328 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/svm/nusvc.py +40 -4
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/svm/nusvr.py +31 -2
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/svm/svc.py +40 -4
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/svm/svr.py +31 -2
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/svm/tests/test_svm.py +12 -20
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/tests/_utils.py +328 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/tests/_utils_spmd.py +185 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/tests/test_common.py +54 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/tests/test_config.py +4 -0
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/tests/test_memory_usage.py +290 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/tests/test_monkeypatch.py +12 -4
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/tests/test_patching.py +21 -25
- scikit_learn_intelex-2024.7.0.data/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability.py +295 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/utils/_namespace.py +1 -1
- {scikit_learn_intelex-2024.5.0.dist-info → scikit_learn_intelex-2024.7.0.dist-info}/METADATA +5 -2
- scikit_learn_intelex-2024.7.0.dist-info/RECORD +122 -0
- {scikit_learn_intelex-2024.5.0.dist-info → scikit_learn_intelex-2024.7.0.dist-info}/WHEEL +1 -1
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/_device_offload.py +0 -257
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/basic_statistics/basic_statistics.py +0 -17
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/svm/_common.py +0 -185
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/tests/_utils.py +0 -173
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/tests/test_memory_usage.py +0 -231
- scikit_learn_intelex-2024.5.0.data/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability_tests.py +0 -428
- scikit_learn_intelex-2024.5.0.dist-info/RECORD +0 -104
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/__main__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/_utils.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/basic_statistics/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/basic_statistics/incremental_basic_statistics.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/covariance/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/decomposition/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/doc/third-party-programs.txt +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/ensemble/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/glob/__main__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/linear_model/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/linear_model/logistic_path.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/manifold/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/manifold/tests/test_tsne.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/metrics/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/metrics/tests/test_metrics.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/model_selection/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/model_selection/tests/test_model_selection.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/neighbors/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/neighbors/tests/test_neighbors.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/_common.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/k_means.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/covariance.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/tests/test_covariance.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/basic_statistics/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/basic_statistics/basic_statistics.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/dbscan.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/kmeans.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/covariance/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/covariance/covariance.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/decomposition/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/decomposition/pca.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/ensemble/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/ensemble/forest.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/linear_model.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/logistic_regression.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/neighbors/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/spmd/neighbors/neighbors.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/svm/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/tests/test_n_jobs_support.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/tests/test_parallel.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/utils/__init__.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/utils/parallel.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/utils/tests/test_finite.py +0 -0
- {scikit_learn_intelex-2024.5.0.data → scikit_learn_intelex-2024.7.0.data}/data/Lib/site-packages/sklearnex/utils/validation.py +0 -0
- {scikit_learn_intelex-2024.5.0.dist-info → scikit_learn_intelex-2024.7.0.dist-info}/LICENSE.txt +0 -0
- {scikit_learn_intelex-2024.5.0.dist-info → scikit_learn_intelex-2024.7.0.dist-info}/top_level.txt +0 -0
|
@@ -1,257 +0,0 @@
|
|
|
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 logging
|
|
18
|
-
import sys
|
|
19
|
-
from collections.abc import Iterable
|
|
20
|
-
from functools import wraps
|
|
21
|
-
|
|
22
|
-
import numpy as np
|
|
23
|
-
|
|
24
|
-
try:
|
|
25
|
-
from dpctl import SyclQueue
|
|
26
|
-
from dpctl.memory import MemoryUSMDevice, as_usm_memory
|
|
27
|
-
from dpctl.tensor import usm_ndarray
|
|
28
|
-
|
|
29
|
-
dpctl_available = True
|
|
30
|
-
except ImportError:
|
|
31
|
-
dpctl_available = False
|
|
32
|
-
|
|
33
|
-
try:
|
|
34
|
-
import dpnp
|
|
35
|
-
|
|
36
|
-
dpnp_available = True
|
|
37
|
-
except ImportError:
|
|
38
|
-
dpnp_available = False
|
|
39
|
-
|
|
40
|
-
from ._config import get_config
|
|
41
|
-
from ._utils import get_patch_message
|
|
42
|
-
|
|
43
|
-
oneapi_is_available = "daal4py.oneapi" in sys.modules
|
|
44
|
-
if oneapi_is_available:
|
|
45
|
-
from daal4py.oneapi import _get_device_name_sycl_ctxt, _get_sycl_ctxt_params
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
class DummySyclQueue:
|
|
49
|
-
"""This class is designed to act like dpctl.SyclQueue
|
|
50
|
-
to allow device dispatching in scenarios when dpctl is not available"""
|
|
51
|
-
|
|
52
|
-
class DummySyclDevice:
|
|
53
|
-
def __init__(self, filter_string):
|
|
54
|
-
self._filter_string = filter_string
|
|
55
|
-
self.is_cpu = "cpu" in filter_string
|
|
56
|
-
self.is_gpu = "gpu" in filter_string
|
|
57
|
-
# TODO: check for possibility of fp64 support
|
|
58
|
-
# on other devices in this dummy class
|
|
59
|
-
self.has_aspect_fp64 = self.is_cpu
|
|
60
|
-
|
|
61
|
-
if not (self.is_cpu):
|
|
62
|
-
logging.warning(
|
|
63
|
-
"Device support is limited. "
|
|
64
|
-
"Please install dpctl for full experience"
|
|
65
|
-
)
|
|
66
|
-
|
|
67
|
-
def get_filter_string(self):
|
|
68
|
-
return self._filter_string
|
|
69
|
-
|
|
70
|
-
def __init__(self, filter_string):
|
|
71
|
-
self.sycl_device = self.DummySyclDevice(filter_string)
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
def _get_device_info_from_daal4py():
|
|
75
|
-
if oneapi_is_available:
|
|
76
|
-
return _get_device_name_sycl_ctxt(), _get_sycl_ctxt_params()
|
|
77
|
-
return None, dict()
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def _get_global_queue():
|
|
81
|
-
target = get_config()["target_offload"]
|
|
82
|
-
d4p_target, _ = _get_device_info_from_daal4py()
|
|
83
|
-
if d4p_target == "host":
|
|
84
|
-
d4p_target = "cpu"
|
|
85
|
-
|
|
86
|
-
QueueClass = DummySyclQueue if not dpctl_available else SyclQueue
|
|
87
|
-
|
|
88
|
-
if target != "auto":
|
|
89
|
-
if d4p_target is not None and d4p_target != target:
|
|
90
|
-
if not isinstance(target, str):
|
|
91
|
-
if d4p_target not in target.sycl_device.get_filter_string():
|
|
92
|
-
raise RuntimeError(
|
|
93
|
-
"Cannot use target offload option "
|
|
94
|
-
"inside daal4py.oneapi.sycl_context"
|
|
95
|
-
)
|
|
96
|
-
else:
|
|
97
|
-
raise RuntimeError(
|
|
98
|
-
"Cannot use target offload option "
|
|
99
|
-
"inside daal4py.oneapi.sycl_context"
|
|
100
|
-
)
|
|
101
|
-
if isinstance(target, QueueClass):
|
|
102
|
-
return target
|
|
103
|
-
return QueueClass(target)
|
|
104
|
-
if d4p_target is not None:
|
|
105
|
-
return QueueClass(d4p_target)
|
|
106
|
-
return None
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
def _transfer_to_host(queue, *data):
|
|
110
|
-
has_usm_data, has_host_data = False, False
|
|
111
|
-
|
|
112
|
-
host_data = []
|
|
113
|
-
for item in data:
|
|
114
|
-
usm_iface = getattr(item, "__sycl_usm_array_interface__", None)
|
|
115
|
-
if usm_iface is not None:
|
|
116
|
-
if not dpctl_available:
|
|
117
|
-
raise RuntimeError(
|
|
118
|
-
"dpctl need to be installed to work "
|
|
119
|
-
"with __sycl_usm_array_interface__"
|
|
120
|
-
)
|
|
121
|
-
if queue is not None:
|
|
122
|
-
if queue.sycl_device != usm_iface["syclobj"].sycl_device:
|
|
123
|
-
raise RuntimeError(
|
|
124
|
-
"Input data shall be located " "on single target device"
|
|
125
|
-
)
|
|
126
|
-
else:
|
|
127
|
-
queue = usm_iface["syclobj"]
|
|
128
|
-
|
|
129
|
-
buffer = as_usm_memory(item).copy_to_host()
|
|
130
|
-
order = "C"
|
|
131
|
-
if usm_iface["strides"] is not None:
|
|
132
|
-
if usm_iface["strides"][0] < usm_iface["strides"][1]:
|
|
133
|
-
order = "F"
|
|
134
|
-
item = np.ndarray(
|
|
135
|
-
shape=usm_iface["shape"],
|
|
136
|
-
dtype=usm_iface["typestr"],
|
|
137
|
-
buffer=buffer,
|
|
138
|
-
order=order,
|
|
139
|
-
)
|
|
140
|
-
has_usm_data = True
|
|
141
|
-
else:
|
|
142
|
-
has_host_data = True
|
|
143
|
-
|
|
144
|
-
mismatch_host_item = usm_iface is None and item is not None and has_usm_data
|
|
145
|
-
mismatch_usm_item = usm_iface is not None and has_host_data
|
|
146
|
-
|
|
147
|
-
if mismatch_host_item or mismatch_usm_item:
|
|
148
|
-
raise RuntimeError("Input data shall be located on single target device")
|
|
149
|
-
|
|
150
|
-
host_data.append(item)
|
|
151
|
-
return queue, host_data
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
def _get_backend(obj, queue, method_name, *data):
|
|
155
|
-
cpu_device = queue is None or queue.sycl_device.is_cpu
|
|
156
|
-
gpu_device = queue is not None and queue.sycl_device.is_gpu
|
|
157
|
-
|
|
158
|
-
if cpu_device:
|
|
159
|
-
patching_status = obj._onedal_cpu_supported(method_name, *data)
|
|
160
|
-
if patching_status.get_status():
|
|
161
|
-
return "onedal", queue, patching_status
|
|
162
|
-
else:
|
|
163
|
-
return "sklearn", None, patching_status
|
|
164
|
-
|
|
165
|
-
_, d4p_options = _get_device_info_from_daal4py()
|
|
166
|
-
allow_fallback_to_host = get_config()["allow_fallback_to_host"] or d4p_options.get(
|
|
167
|
-
"host_offload_on_fail", False
|
|
168
|
-
)
|
|
169
|
-
|
|
170
|
-
if gpu_device:
|
|
171
|
-
patching_status = obj._onedal_gpu_supported(method_name, *data)
|
|
172
|
-
if patching_status.get_status():
|
|
173
|
-
return "onedal", queue, patching_status
|
|
174
|
-
else:
|
|
175
|
-
if allow_fallback_to_host:
|
|
176
|
-
patching_status = obj._onedal_cpu_supported(method_name, *data)
|
|
177
|
-
if patching_status.get_status():
|
|
178
|
-
return "onedal", None, patching_status
|
|
179
|
-
else:
|
|
180
|
-
return "sklearn", None, patching_status
|
|
181
|
-
else:
|
|
182
|
-
return "sklearn", None, patching_status
|
|
183
|
-
|
|
184
|
-
raise RuntimeError("Device support is not implemented")
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
def dispatch(obj, method_name, branches, *args, **kwargs):
|
|
188
|
-
q = _get_global_queue()
|
|
189
|
-
q, hostargs = _transfer_to_host(q, *args)
|
|
190
|
-
q, hostvalues = _transfer_to_host(q, *kwargs.values())
|
|
191
|
-
hostkwargs = dict(zip(kwargs.keys(), hostvalues))
|
|
192
|
-
|
|
193
|
-
backend, q, patching_status = _get_backend(obj, q, method_name, *hostargs)
|
|
194
|
-
|
|
195
|
-
if backend == "onedal":
|
|
196
|
-
patching_status.write_log(queue=q)
|
|
197
|
-
return branches[backend](obj, *hostargs, **hostkwargs, queue=q)
|
|
198
|
-
if backend == "sklearn":
|
|
199
|
-
patching_status.write_log()
|
|
200
|
-
return branches[backend](obj, *hostargs, **hostkwargs)
|
|
201
|
-
raise RuntimeError(
|
|
202
|
-
f"Undefined backend {backend} in " f"{obj.__class__.__name__}.{method_name}"
|
|
203
|
-
)
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
def _copy_to_usm(queue, array):
|
|
207
|
-
if not dpctl_available:
|
|
208
|
-
raise RuntimeError(
|
|
209
|
-
"dpctl need to be installed to work " "with __sycl_usm_array_interface__"
|
|
210
|
-
)
|
|
211
|
-
|
|
212
|
-
if hasattr(array, "__array__"):
|
|
213
|
-
|
|
214
|
-
try:
|
|
215
|
-
mem = MemoryUSMDevice(array.nbytes, queue=queue)
|
|
216
|
-
mem.copy_from_host(array.tobytes())
|
|
217
|
-
return usm_ndarray(array.shape, array.dtype, buffer=mem)
|
|
218
|
-
except ValueError as e:
|
|
219
|
-
# ValueError will raise if device does not support the dtype
|
|
220
|
-
# retry with float32 (needed for fp16 and fp64 support issues)
|
|
221
|
-
# try again as float32, if it is a float32 just raise the error.
|
|
222
|
-
if array.dtype == np.float32:
|
|
223
|
-
raise e
|
|
224
|
-
return _copy_to_usm(queue, array.astype(np.float32))
|
|
225
|
-
else:
|
|
226
|
-
if isinstance(array, Iterable):
|
|
227
|
-
array = [_copy_to_usm(queue, i) for i in array]
|
|
228
|
-
return array
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
if dpnp_available:
|
|
232
|
-
|
|
233
|
-
def _convert_to_dpnp(array):
|
|
234
|
-
if isinstance(array, usm_ndarray):
|
|
235
|
-
return dpnp.array(array, copy=False)
|
|
236
|
-
elif isinstance(array, Iterable):
|
|
237
|
-
for i in range(len(array)):
|
|
238
|
-
array[i] = _convert_to_dpnp(array[i])
|
|
239
|
-
return array
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
def wrap_output_data(func):
|
|
243
|
-
@wraps(func)
|
|
244
|
-
def wrapper(self, *args, **kwargs):
|
|
245
|
-
data = (*args, *kwargs.values())
|
|
246
|
-
if len(data) == 0:
|
|
247
|
-
usm_iface = None
|
|
248
|
-
else:
|
|
249
|
-
usm_iface = getattr(data[0], "__sycl_usm_array_interface__", None)
|
|
250
|
-
result = func(self, *args, **kwargs)
|
|
251
|
-
if usm_iface is not None:
|
|
252
|
-
result = _copy_to_usm(usm_iface["syclobj"], result)
|
|
253
|
-
if dpnp_available and isinstance(data[0], dpnp.ndarray):
|
|
254
|
-
result = _convert_to_dpnp(result)
|
|
255
|
-
return result
|
|
256
|
-
|
|
257
|
-
return wrapper
|
|
@@ -1,17 +0,0 @@
|
|
|
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
|
-
from onedal.basic_statistics import BasicStatistics
|
|
@@ -1,185 +0,0 @@
|
|
|
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 abc import ABC
|
|
18
|
-
|
|
19
|
-
import numpy as np
|
|
20
|
-
from sklearn.calibration import CalibratedClassifierCV
|
|
21
|
-
from sklearn.model_selection import StratifiedKFold
|
|
22
|
-
from sklearn.preprocessing import LabelEncoder
|
|
23
|
-
|
|
24
|
-
from daal4py.sklearn._utils import sklearn_check_version
|
|
25
|
-
from onedal.utils import _column_or_1d
|
|
26
|
-
|
|
27
|
-
from .._utils import PatchingConditionsChain
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
def get_dual_coef(self):
|
|
31
|
-
return self.dual_coef_
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
def set_dual_coef(self, value):
|
|
35
|
-
self.dual_coef_ = value
|
|
36
|
-
if hasattr(self, "_onedal_estimator"):
|
|
37
|
-
self._onedal_estimator.dual_coef_ = value
|
|
38
|
-
if not self._is_in_fit:
|
|
39
|
-
del self._onedal_estimator._onedal_model
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
def get_intercept(self):
|
|
43
|
-
return self._intercept_
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
def set_intercept(self, value):
|
|
47
|
-
self._intercept_ = value
|
|
48
|
-
if hasattr(self, "_onedal_estimator"):
|
|
49
|
-
self._onedal_estimator.intercept_ = value
|
|
50
|
-
if not self._is_in_fit:
|
|
51
|
-
del self._onedal_estimator._onedal_model
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
class BaseSVM(ABC):
|
|
55
|
-
def _onedal_gpu_supported(self, method_name, *data):
|
|
56
|
-
patching_status = PatchingConditionsChain(f"sklearn.{method_name}")
|
|
57
|
-
patching_status.and_conditions([(False, "GPU offloading is not supported.")])
|
|
58
|
-
return patching_status
|
|
59
|
-
|
|
60
|
-
def _onedal_cpu_supported(self, method_name, *data):
|
|
61
|
-
class_name = self.__class__.__name__
|
|
62
|
-
patching_status = PatchingConditionsChain(
|
|
63
|
-
f"sklearn.svm.{class_name}.{method_name}"
|
|
64
|
-
)
|
|
65
|
-
if method_name == "fit":
|
|
66
|
-
patching_status.and_conditions(
|
|
67
|
-
[
|
|
68
|
-
(
|
|
69
|
-
self.kernel in ["linear", "rbf", "poly", "sigmoid"],
|
|
70
|
-
f'Kernel is "{self.kernel}" while '
|
|
71
|
-
'"linear", "rbf", "poly" and "sigmoid" are only supported.',
|
|
72
|
-
)
|
|
73
|
-
]
|
|
74
|
-
)
|
|
75
|
-
return patching_status
|
|
76
|
-
inference_methods = (
|
|
77
|
-
["predict"]
|
|
78
|
-
if class_name.endswith("R")
|
|
79
|
-
else ["predict", "predict_proba", "decision_function", "score"]
|
|
80
|
-
)
|
|
81
|
-
if method_name in inference_methods:
|
|
82
|
-
patching_status.and_conditions(
|
|
83
|
-
[(hasattr(self, "_onedal_estimator"), "oneDAL model was not trained.")]
|
|
84
|
-
)
|
|
85
|
-
return patching_status
|
|
86
|
-
raise RuntimeError(f"Unknown method {method_name} in {class_name}")
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
class BaseSVC(BaseSVM):
|
|
90
|
-
def _compute_balanced_class_weight(self, y):
|
|
91
|
-
y_ = _column_or_1d(y)
|
|
92
|
-
classes, _ = np.unique(y_, return_inverse=True)
|
|
93
|
-
|
|
94
|
-
le = LabelEncoder()
|
|
95
|
-
y_ind = le.fit_transform(y_)
|
|
96
|
-
if not all(np.in1d(classes, le.classes_)):
|
|
97
|
-
raise ValueError("classes should have valid labels that are in y")
|
|
98
|
-
|
|
99
|
-
recip_freq = len(y_) / (len(le.classes_) * np.bincount(y_ind).astype(np.float64))
|
|
100
|
-
return recip_freq[le.transform(classes)]
|
|
101
|
-
|
|
102
|
-
def _fit_proba(self, X, y, sample_weight=None, queue=None):
|
|
103
|
-
params = self.get_params()
|
|
104
|
-
params["probability"] = False
|
|
105
|
-
params["decision_function_shape"] = "ovr"
|
|
106
|
-
clf_base = self.__class__(**params)
|
|
107
|
-
|
|
108
|
-
try:
|
|
109
|
-
n_splits = 5
|
|
110
|
-
n_jobs = n_splits if queue is None or queue.sycl_device.is_cpu else 1
|
|
111
|
-
cv = StratifiedKFold(
|
|
112
|
-
n_splits=n_splits, shuffle=True, random_state=self.random_state
|
|
113
|
-
)
|
|
114
|
-
self.clf_prob = CalibratedClassifierCV(
|
|
115
|
-
clf_base, ensemble=False, cv=cv, method="sigmoid", n_jobs=n_jobs
|
|
116
|
-
)
|
|
117
|
-
self.clf_prob.fit(X, y, sample_weight)
|
|
118
|
-
except ValueError:
|
|
119
|
-
clf_base = clf_base.fit(X, y, sample_weight)
|
|
120
|
-
self.clf_prob = CalibratedClassifierCV(
|
|
121
|
-
clf_base, cv="prefit", method="sigmoid"
|
|
122
|
-
)
|
|
123
|
-
self.clf_prob.fit(X, y, sample_weight)
|
|
124
|
-
|
|
125
|
-
def _save_attributes(self):
|
|
126
|
-
self.support_vectors_ = self._onedal_estimator.support_vectors_
|
|
127
|
-
self.n_features_in_ = self._onedal_estimator.n_features_in_
|
|
128
|
-
self.fit_status_ = 0
|
|
129
|
-
self.dual_coef_ = self._onedal_estimator.dual_coef_
|
|
130
|
-
self.shape_fit_ = self._onedal_estimator.class_weight_
|
|
131
|
-
self.classes_ = self._onedal_estimator.classes_
|
|
132
|
-
self.class_weight_ = self._onedal_estimator.class_weight_
|
|
133
|
-
self.support_ = self._onedal_estimator.support_
|
|
134
|
-
|
|
135
|
-
self._intercept_ = self._onedal_estimator.intercept_
|
|
136
|
-
self._n_support = self._onedal_estimator._n_support
|
|
137
|
-
self._sparse = False
|
|
138
|
-
self._gamma = self._onedal_estimator._gamma
|
|
139
|
-
if self.probability:
|
|
140
|
-
length = int(len(self.classes_) * (len(self.classes_) - 1) / 2)
|
|
141
|
-
self._probA = np.zeros(length)
|
|
142
|
-
self._probB = np.zeros(length)
|
|
143
|
-
else:
|
|
144
|
-
self._probA = np.empty(0)
|
|
145
|
-
self._probB = np.empty(0)
|
|
146
|
-
|
|
147
|
-
self._dual_coef_ = property(get_dual_coef, set_dual_coef)
|
|
148
|
-
self.intercept_ = property(get_intercept, set_intercept)
|
|
149
|
-
|
|
150
|
-
self._is_in_fit = True
|
|
151
|
-
self._dual_coef_ = self.dual_coef_
|
|
152
|
-
self.intercept_ = self._intercept_
|
|
153
|
-
self._is_in_fit = False
|
|
154
|
-
|
|
155
|
-
if sklearn_check_version("1.1"):
|
|
156
|
-
length = int(len(self.classes_) * (len(self.classes_) - 1) / 2)
|
|
157
|
-
self.n_iter_ = np.full((length,), self._onedal_estimator.n_iter_)
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
class BaseSVR(BaseSVM):
|
|
161
|
-
def _save_attributes(self):
|
|
162
|
-
self.support_vectors_ = self._onedal_estimator.support_vectors_
|
|
163
|
-
self.n_features_in_ = self._onedal_estimator.n_features_in_
|
|
164
|
-
self.fit_status_ = 0
|
|
165
|
-
self.dual_coef_ = self._onedal_estimator.dual_coef_
|
|
166
|
-
self.shape_fit_ = self._onedal_estimator.shape_fit_
|
|
167
|
-
self.support_ = self._onedal_estimator.support_
|
|
168
|
-
|
|
169
|
-
self._intercept_ = self._onedal_estimator.intercept_
|
|
170
|
-
self._n_support = [self.support_vectors_.shape[0]]
|
|
171
|
-
self._sparse = False
|
|
172
|
-
self._gamma = self._onedal_estimator._gamma
|
|
173
|
-
self._probA = None
|
|
174
|
-
self._probB = None
|
|
175
|
-
|
|
176
|
-
self._dual_coef_ = property(get_dual_coef, set_dual_coef)
|
|
177
|
-
self.intercept_ = property(get_intercept, set_intercept)
|
|
178
|
-
|
|
179
|
-
self._is_in_fit = True
|
|
180
|
-
self._dual_coef_ = self.dual_coef_
|
|
181
|
-
self.intercept_ = self._intercept_
|
|
182
|
-
self._is_in_fit = False
|
|
183
|
-
|
|
184
|
-
if sklearn_check_version("1.1"):
|
|
185
|
-
self.n_iter_ = self._onedal_estimator.n_iter_
|
|
@@ -1,173 +0,0 @@
|
|
|
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
|
-
from inspect import isclass
|
|
18
|
-
|
|
19
|
-
import numpy as np
|
|
20
|
-
from sklearn import clone
|
|
21
|
-
from sklearn.base import (
|
|
22
|
-
BaseEstimator,
|
|
23
|
-
ClassifierMixin,
|
|
24
|
-
ClusterMixin,
|
|
25
|
-
OutlierMixin,
|
|
26
|
-
RegressorMixin,
|
|
27
|
-
TransformerMixin,
|
|
28
|
-
)
|
|
29
|
-
from sklearn.datasets import load_diabetes, load_iris
|
|
30
|
-
from sklearn.neighbors._base import KNeighborsMixin
|
|
31
|
-
|
|
32
|
-
from onedal.tests.utils._dataframes_support import _convert_to_dataframe
|
|
33
|
-
from sklearnex import get_patch_map, patch_sklearn, sklearn_is_patched, unpatch_sklearn
|
|
34
|
-
from sklearnex.linear_model import LogisticRegression
|
|
35
|
-
from sklearnex.neighbors import (
|
|
36
|
-
KNeighborsClassifier,
|
|
37
|
-
KNeighborsRegressor,
|
|
38
|
-
LocalOutlierFactor,
|
|
39
|
-
NearestNeighbors,
|
|
40
|
-
)
|
|
41
|
-
from sklearnex.svm import SVC, NuSVC
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
def _load_all_models(with_sklearnex=True, estimator=True):
|
|
45
|
-
# insure that patch state is correct as dictated by patch_sklearn boolean
|
|
46
|
-
# and return it to the previous state no matter what occurs.
|
|
47
|
-
already_patched_map = sklearn_is_patched(return_map=True)
|
|
48
|
-
already_patched = any(already_patched_map.values())
|
|
49
|
-
try:
|
|
50
|
-
if with_sklearnex:
|
|
51
|
-
patch_sklearn()
|
|
52
|
-
elif already_patched:
|
|
53
|
-
unpatch_sklearn()
|
|
54
|
-
|
|
55
|
-
models = {}
|
|
56
|
-
for patch_infos in get_patch_map().values():
|
|
57
|
-
candidate = getattr(patch_infos[0][0][0], patch_infos[0][0][1], None)
|
|
58
|
-
if candidate is not None and isclass(candidate) == estimator:
|
|
59
|
-
if not estimator or issubclass(candidate, BaseEstimator):
|
|
60
|
-
models[patch_infos[0][0][1]] = candidate
|
|
61
|
-
finally:
|
|
62
|
-
if with_sklearnex:
|
|
63
|
-
unpatch_sklearn()
|
|
64
|
-
# both branches are now in an unpatched state, repatch as necessary
|
|
65
|
-
if already_patched:
|
|
66
|
-
patch_sklearn(name=[i for i in already_patched_map if already_patched_map[i]])
|
|
67
|
-
|
|
68
|
-
return models
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
PATCHED_MODELS = _load_all_models(with_sklearnex=True)
|
|
72
|
-
UNPATCHED_MODELS = _load_all_models(with_sklearnex=False)
|
|
73
|
-
|
|
74
|
-
PATCHED_FUNCTIONS = _load_all_models(with_sklearnex=True, estimator=False)
|
|
75
|
-
UNPATCHED_FUNCTIONS = _load_all_models(with_sklearnex=False, estimator=False)
|
|
76
|
-
|
|
77
|
-
mixin_map = [
|
|
78
|
-
[
|
|
79
|
-
ClassifierMixin,
|
|
80
|
-
["decision_function", "predict", "predict_proba", "predict_log_proba", "score"],
|
|
81
|
-
"classification",
|
|
82
|
-
],
|
|
83
|
-
[RegressorMixin, ["predict", "score"], "regression"],
|
|
84
|
-
[ClusterMixin, ["fit_predict"], "classification"],
|
|
85
|
-
[TransformerMixin, ["fit_transform", "transform", "score"], "classification"],
|
|
86
|
-
[OutlierMixin, ["fit_predict", "predict"], "classification"],
|
|
87
|
-
[KNeighborsMixin, ["kneighbors"], None],
|
|
88
|
-
]
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
class _sklearn_clone_dict(dict):
|
|
92
|
-
|
|
93
|
-
def __getitem__(self, key):
|
|
94
|
-
return clone(super().__getitem__(key))
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
SPECIAL_INSTANCES = _sklearn_clone_dict(
|
|
98
|
-
{
|
|
99
|
-
str(i): i
|
|
100
|
-
for i in [
|
|
101
|
-
LocalOutlierFactor(novelty=True),
|
|
102
|
-
SVC(probability=True),
|
|
103
|
-
NuSVC(probability=True),
|
|
104
|
-
KNeighborsClassifier(algorithm="brute"),
|
|
105
|
-
KNeighborsRegressor(algorithm="brute"),
|
|
106
|
-
NearestNeighbors(algorithm="brute"),
|
|
107
|
-
LogisticRegression(solver="newton-cg"),
|
|
108
|
-
]
|
|
109
|
-
}
|
|
110
|
-
)
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
def gen_models_info(algorithms):
|
|
114
|
-
output = []
|
|
115
|
-
for i in algorithms:
|
|
116
|
-
|
|
117
|
-
if i in PATCHED_MODELS:
|
|
118
|
-
est = PATCHED_MODELS[i]
|
|
119
|
-
elif i in SPECIAL_INSTANCES:
|
|
120
|
-
est = SPECIAL_INSTANCES[i].__class__
|
|
121
|
-
else:
|
|
122
|
-
raise KeyError(f"Unrecognized sklearnex estimator: {i}")
|
|
123
|
-
|
|
124
|
-
methods = set()
|
|
125
|
-
candidates = set(
|
|
126
|
-
[i for i in dir(est) if not i.startswith("_") and not i.endswith("_")]
|
|
127
|
-
)
|
|
128
|
-
|
|
129
|
-
for mixin, method, _ in mixin_map:
|
|
130
|
-
if issubclass(est, mixin):
|
|
131
|
-
methods |= candidates & set(method)
|
|
132
|
-
|
|
133
|
-
output += [[i, j] for j in methods] if methods else [[i, None]]
|
|
134
|
-
|
|
135
|
-
# In the case that no methods are available, set method to None.
|
|
136
|
-
# This will allow estimators without mixins to still test the fit
|
|
137
|
-
# method in various tests.
|
|
138
|
-
return output
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
def gen_dataset(estimator, queue=None, target_df=None, dtype=np.float64):
|
|
142
|
-
dataset = None
|
|
143
|
-
name = estimator.__class__.__name__
|
|
144
|
-
est = PATCHED_MODELS[name]
|
|
145
|
-
for mixin, _, data in mixin_map:
|
|
146
|
-
if issubclass(est, mixin) and data is not None:
|
|
147
|
-
dataset = data
|
|
148
|
-
# load data
|
|
149
|
-
if dataset == "classification" or dataset is None:
|
|
150
|
-
X, y = load_iris(return_X_y=True)
|
|
151
|
-
elif dataset == "regression":
|
|
152
|
-
X, y = load_diabetes(return_X_y=True)
|
|
153
|
-
else:
|
|
154
|
-
raise ValueError("Unknown dataset type")
|
|
155
|
-
|
|
156
|
-
X = _convert_to_dataframe(X, sycl_queue=queue, target_df=target_df, dtype=dtype)
|
|
157
|
-
y = _convert_to_dataframe(y, sycl_queue=queue, target_df=target_df, dtype=dtype)
|
|
158
|
-
return X, y
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
DTYPES = [
|
|
162
|
-
np.int8,
|
|
163
|
-
np.int16,
|
|
164
|
-
np.int32,
|
|
165
|
-
np.int64,
|
|
166
|
-
np.float16,
|
|
167
|
-
np.float32,
|
|
168
|
-
np.float64,
|
|
169
|
-
np.uint8,
|
|
170
|
-
np.uint16,
|
|
171
|
-
np.uint32,
|
|
172
|
-
np.uint64,
|
|
173
|
-
]
|