scikit-learn-intelex 2024.5.0__py39-none-win_amd64.whl → 2024.7.0__py39-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
|
@@ -29,7 +29,7 @@ from sklearn.ensemble._forest import ForestClassifier as sklearn_ForestClassifie
|
|
|
29
29
|
from sklearn.ensemble._forest import ForestRegressor as sklearn_ForestRegressor
|
|
30
30
|
from sklearn.ensemble._forest import _get_n_samples_bootstrap
|
|
31
31
|
from sklearn.exceptions import DataConversionWarning
|
|
32
|
-
from sklearn.metrics import accuracy_score
|
|
32
|
+
from sklearn.metrics import accuracy_score, r2_score
|
|
33
33
|
from sklearn.tree import (
|
|
34
34
|
DecisionTreeClassifier,
|
|
35
35
|
DecisionTreeRegressor,
|
|
@@ -38,7 +38,12 @@ from sklearn.tree import (
|
|
|
38
38
|
)
|
|
39
39
|
from sklearn.tree._tree import Tree
|
|
40
40
|
from sklearn.utils import check_random_state, deprecated
|
|
41
|
-
from sklearn.utils.validation import
|
|
41
|
+
from sklearn.utils.validation import (
|
|
42
|
+
_check_sample_weight,
|
|
43
|
+
check_array,
|
|
44
|
+
check_is_fitted,
|
|
45
|
+
check_X_y,
|
|
46
|
+
)
|
|
42
47
|
|
|
43
48
|
from daal4py.sklearn._n_jobs_support import control_n_jobs
|
|
44
49
|
from daal4py.sklearn._utils import (
|
|
@@ -70,14 +75,15 @@ class BaseForest(ABC):
|
|
|
70
75
|
X, y = self._validate_data(
|
|
71
76
|
X,
|
|
72
77
|
y,
|
|
73
|
-
multi_output=
|
|
78
|
+
multi_output=True,
|
|
74
79
|
accept_sparse=False,
|
|
75
80
|
dtype=[np.float64, np.float32],
|
|
76
81
|
force_all_finite=False,
|
|
82
|
+
ensure_2d=True,
|
|
77
83
|
)
|
|
78
84
|
|
|
79
85
|
if sample_weight is not None:
|
|
80
|
-
sample_weight =
|
|
86
|
+
sample_weight = _check_sample_weight(sample_weight, X)
|
|
81
87
|
|
|
82
88
|
if y.ndim == 2 and y.shape[1] == 1:
|
|
83
89
|
warnings.warn(
|
|
@@ -97,8 +103,6 @@ class BaseForest(ABC):
|
|
|
97
103
|
|
|
98
104
|
y, expanded_class_weight = self._validate_y_class_weight(y)
|
|
99
105
|
|
|
100
|
-
self.n_features_in_ = X.shape[1]
|
|
101
|
-
|
|
102
106
|
if expanded_class_weight is not None:
|
|
103
107
|
if sample_weight is not None:
|
|
104
108
|
sample_weight = sample_weight * expanded_class_weight
|
|
@@ -114,7 +118,9 @@ class BaseForest(ABC):
|
|
|
114
118
|
"min_samples_split": self.min_samples_split,
|
|
115
119
|
"min_samples_leaf": self.min_samples_leaf,
|
|
116
120
|
"min_weight_fraction_leaf": self.min_weight_fraction_leaf,
|
|
117
|
-
"max_features": self.
|
|
121
|
+
"max_features": self._to_absolute_max_features(
|
|
122
|
+
self.max_features, self.n_features_in_
|
|
123
|
+
),
|
|
118
124
|
"max_leaf_nodes": self.max_leaf_nodes,
|
|
119
125
|
"min_impurity_decrease": self.min_impurity_decrease,
|
|
120
126
|
"bootstrap": self.bootstrap,
|
|
@@ -174,6 +180,45 @@ class BaseForest(ABC):
|
|
|
174
180
|
self._validate_estimator()
|
|
175
181
|
return self
|
|
176
182
|
|
|
183
|
+
def _to_absolute_max_features(self, max_features, n_features):
|
|
184
|
+
if max_features is None:
|
|
185
|
+
return n_features
|
|
186
|
+
if isinstance(max_features, str):
|
|
187
|
+
if max_features == "auto":
|
|
188
|
+
if not sklearn_check_version("1.3"):
|
|
189
|
+
if sklearn_check_version("1.1"):
|
|
190
|
+
warnings.warn(
|
|
191
|
+
"`max_features='auto'` has been deprecated in 1.1 "
|
|
192
|
+
"and will be removed in 1.3. To keep the past behaviour, "
|
|
193
|
+
"explicitly set `max_features=1.0` or remove this "
|
|
194
|
+
"parameter as it is also the default value for "
|
|
195
|
+
"RandomForestRegressors and ExtraTreesRegressors.",
|
|
196
|
+
FutureWarning,
|
|
197
|
+
)
|
|
198
|
+
return (
|
|
199
|
+
max(1, int(np.sqrt(n_features)))
|
|
200
|
+
if isinstance(self, ForestClassifier)
|
|
201
|
+
else n_features
|
|
202
|
+
)
|
|
203
|
+
if max_features == "sqrt":
|
|
204
|
+
return max(1, int(np.sqrt(n_features)))
|
|
205
|
+
if max_features == "log2":
|
|
206
|
+
return max(1, int(np.log2(n_features)))
|
|
207
|
+
allowed_string_values = (
|
|
208
|
+
'"sqrt" or "log2"'
|
|
209
|
+
if sklearn_check_version("1.3")
|
|
210
|
+
else '"auto", "sqrt" or "log2"'
|
|
211
|
+
)
|
|
212
|
+
raise ValueError(
|
|
213
|
+
"Invalid value for max_features. Allowed string "
|
|
214
|
+
f"values are {allowed_string_values}."
|
|
215
|
+
)
|
|
216
|
+
if isinstance(max_features, (numbers.Integral, np.integer)):
|
|
217
|
+
return max_features
|
|
218
|
+
if max_features > 0.0:
|
|
219
|
+
return max(1, int(max_features * n_features))
|
|
220
|
+
return 0
|
|
221
|
+
|
|
177
222
|
def _check_parameters(self):
|
|
178
223
|
if isinstance(self.min_samples_leaf, numbers.Integral):
|
|
179
224
|
if not 1 <= self.min_samples_leaf:
|
|
@@ -249,38 +294,6 @@ class BaseForest(ABC):
|
|
|
249
294
|
"min_bin_size must be integral number but was " "%r" % self.min_bin_size
|
|
250
295
|
)
|
|
251
296
|
|
|
252
|
-
def check_sample_weight(self, sample_weight, X, dtype=None):
|
|
253
|
-
n_samples = _num_samples(X)
|
|
254
|
-
|
|
255
|
-
if dtype is not None and dtype not in [np.float32, np.float64]:
|
|
256
|
-
dtype = np.float64
|
|
257
|
-
|
|
258
|
-
if sample_weight is None:
|
|
259
|
-
sample_weight = np.ones(n_samples, dtype=dtype)
|
|
260
|
-
elif isinstance(sample_weight, numbers.Number):
|
|
261
|
-
sample_weight = np.full(n_samples, sample_weight, dtype=dtype)
|
|
262
|
-
else:
|
|
263
|
-
if dtype is None:
|
|
264
|
-
dtype = [np.float64, np.float32]
|
|
265
|
-
sample_weight = check_array(
|
|
266
|
-
sample_weight,
|
|
267
|
-
accept_sparse=False,
|
|
268
|
-
ensure_2d=False,
|
|
269
|
-
dtype=dtype,
|
|
270
|
-
order="C",
|
|
271
|
-
force_all_finite=False,
|
|
272
|
-
)
|
|
273
|
-
if sample_weight.ndim != 1:
|
|
274
|
-
raise ValueError("Sample weights must be 1D array or scalar")
|
|
275
|
-
|
|
276
|
-
if sample_weight.shape != (n_samples,):
|
|
277
|
-
raise ValueError(
|
|
278
|
-
"sample_weight.shape == {}, expected {}!".format(
|
|
279
|
-
sample_weight.shape, (n_samples,)
|
|
280
|
-
)
|
|
281
|
-
)
|
|
282
|
-
return sample_weight
|
|
283
|
-
|
|
284
297
|
@property
|
|
285
298
|
def estimators_(self):
|
|
286
299
|
if hasattr(self, "_cached_estimators_"):
|
|
@@ -518,7 +531,7 @@ class ForestClassifier(sklearn_ForestClassifier, BaseForest):
|
|
|
518
531
|
)
|
|
519
532
|
|
|
520
533
|
if patching_status.get_status():
|
|
521
|
-
X, y =
|
|
534
|
+
X, y = check_X_y(
|
|
522
535
|
X,
|
|
523
536
|
y,
|
|
524
537
|
multi_output=True,
|
|
@@ -738,6 +751,10 @@ class ForestClassifier(sklearn_ForestClassifier, BaseForest):
|
|
|
738
751
|
or self.estimator.__class__ == DecisionTreeClassifier,
|
|
739
752
|
"ExtraTrees only supported starting from oneDAL version 2023.1",
|
|
740
753
|
),
|
|
754
|
+
(
|
|
755
|
+
not self.oob_score,
|
|
756
|
+
"oob_scores using r2 or accuracy not implemented.",
|
|
757
|
+
),
|
|
741
758
|
(sample_weight is None, "sample_weight is not supported."),
|
|
742
759
|
]
|
|
743
760
|
)
|
|
@@ -780,24 +797,43 @@ class ForestClassifier(sklearn_ForestClassifier, BaseForest):
|
|
|
780
797
|
check_is_fitted(self, "_onedal_estimator")
|
|
781
798
|
|
|
782
799
|
if sklearn_check_version("1.0"):
|
|
783
|
-
self.
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
800
|
+
X = self._validate_data(
|
|
801
|
+
X,
|
|
802
|
+
dtype=[np.float64, np.float32],
|
|
803
|
+
force_all_finite=False,
|
|
804
|
+
reset=False,
|
|
805
|
+
ensure_2d=True,
|
|
806
|
+
)
|
|
807
|
+
else:
|
|
808
|
+
X = check_array(
|
|
809
|
+
X,
|
|
810
|
+
dtype=[np.float64, np.float32],
|
|
811
|
+
force_all_finite=False,
|
|
812
|
+
) # Warning, order of dtype matters
|
|
813
|
+
self._check_n_features(X, reset=False)
|
|
790
814
|
|
|
791
815
|
res = self._onedal_estimator.predict(X, queue=queue)
|
|
792
816
|
return np.take(self.classes_, res.ravel().astype(np.int64, casting="unsafe"))
|
|
793
817
|
|
|
794
818
|
def _onedal_predict_proba(self, X, queue=None):
|
|
795
|
-
X = check_array(X, dtype=[np.float64, np.float32], force_all_finite=False)
|
|
796
819
|
check_is_fitted(self, "_onedal_estimator")
|
|
797
820
|
|
|
798
|
-
self._check_n_features(X, reset=False)
|
|
799
821
|
if sklearn_check_version("1.0"):
|
|
800
|
-
self.
|
|
822
|
+
X = self._validate_data(
|
|
823
|
+
X,
|
|
824
|
+
dtype=[np.float64, np.float32],
|
|
825
|
+
force_all_finite=False,
|
|
826
|
+
reset=False,
|
|
827
|
+
ensure_2d=True,
|
|
828
|
+
)
|
|
829
|
+
else:
|
|
830
|
+
X = check_array(
|
|
831
|
+
X,
|
|
832
|
+
dtype=[np.float64, np.float32],
|
|
833
|
+
force_all_finite=False,
|
|
834
|
+
) # Warning, order of dtype matters
|
|
835
|
+
self._check_n_features(X, reset=False)
|
|
836
|
+
|
|
801
837
|
return self._onedal_estimator.predict_proba(X, queue=queue)
|
|
802
838
|
|
|
803
839
|
def _onedal_score(self, X, y, sample_weight=None, queue=None):
|
|
@@ -914,7 +950,7 @@ class ForestRegressor(sklearn_ForestRegressor, BaseForest):
|
|
|
914
950
|
)
|
|
915
951
|
|
|
916
952
|
if patching_status.get_status():
|
|
917
|
-
X, y =
|
|
953
|
+
X, y = check_X_y(
|
|
918
954
|
X,
|
|
919
955
|
y,
|
|
920
956
|
multi_output=True,
|
|
@@ -996,7 +1032,7 @@ class ForestRegressor(sklearn_ForestRegressor, BaseForest):
|
|
|
996
1032
|
]
|
|
997
1033
|
)
|
|
998
1034
|
|
|
999
|
-
elif method_name
|
|
1035
|
+
elif method_name in ["predict", "score"]:
|
|
1000
1036
|
X = data[0]
|
|
1001
1037
|
|
|
1002
1038
|
patching_status.and_conditions(
|
|
@@ -1046,11 +1082,12 @@ class ForestRegressor(sklearn_ForestRegressor, BaseForest):
|
|
|
1046
1082
|
or self.estimator.__class__ == DecisionTreeClassifier,
|
|
1047
1083
|
"ExtraTrees only supported starting from oneDAL version 2023.1",
|
|
1048
1084
|
),
|
|
1085
|
+
(not self.oob_score, "oob_score value is not sklearn conformant."),
|
|
1049
1086
|
(sample_weight is None, "sample_weight is not supported."),
|
|
1050
1087
|
]
|
|
1051
1088
|
)
|
|
1052
1089
|
|
|
1053
|
-
elif method_name
|
|
1090
|
+
elif method_name in ["predict", "score"]:
|
|
1054
1091
|
X = data[0]
|
|
1055
1092
|
|
|
1056
1093
|
patching_status.and_conditions(
|
|
@@ -1083,16 +1120,28 @@ class ForestRegressor(sklearn_ForestRegressor, BaseForest):
|
|
|
1083
1120
|
return patching_status
|
|
1084
1121
|
|
|
1085
1122
|
def _onedal_predict(self, X, queue=None):
|
|
1086
|
-
X = check_array(
|
|
1087
|
-
X, dtype=[np.float64, np.float32], force_all_finite=False
|
|
1088
|
-
) # Warning, order of dtype matters
|
|
1089
1123
|
check_is_fitted(self, "_onedal_estimator")
|
|
1090
1124
|
|
|
1091
1125
|
if sklearn_check_version("1.0"):
|
|
1092
|
-
self.
|
|
1126
|
+
X = self._validate_data(
|
|
1127
|
+
X,
|
|
1128
|
+
dtype=[np.float64, np.float32],
|
|
1129
|
+
force_all_finite=False,
|
|
1130
|
+
reset=False,
|
|
1131
|
+
ensure_2d=True,
|
|
1132
|
+
) # Warning, order of dtype matters
|
|
1133
|
+
else:
|
|
1134
|
+
X = check_array(
|
|
1135
|
+
X, dtype=[np.float64, np.float32], force_all_finite=False
|
|
1136
|
+
) # Warning, order of dtype matters
|
|
1093
1137
|
|
|
1094
1138
|
return self._onedal_estimator.predict(X, queue=queue)
|
|
1095
1139
|
|
|
1140
|
+
def _onedal_score(self, X, y, sample_weight=None, queue=None):
|
|
1141
|
+
return r2_score(
|
|
1142
|
+
y, self._onedal_predict(X, queue=queue), sample_weight=sample_weight
|
|
1143
|
+
)
|
|
1144
|
+
|
|
1096
1145
|
def fit(self, X, y, sample_weight=None):
|
|
1097
1146
|
dispatch(
|
|
1098
1147
|
self,
|
|
@@ -1119,8 +1168,23 @@ class ForestRegressor(sklearn_ForestRegressor, BaseForest):
|
|
|
1119
1168
|
X,
|
|
1120
1169
|
)
|
|
1121
1170
|
|
|
1171
|
+
@wrap_output_data
|
|
1172
|
+
def score(self, X, y, sample_weight=None):
|
|
1173
|
+
return dispatch(
|
|
1174
|
+
self,
|
|
1175
|
+
"score",
|
|
1176
|
+
{
|
|
1177
|
+
"onedal": self.__class__._onedal_score,
|
|
1178
|
+
"sklearn": sklearn_ForestRegressor.score,
|
|
1179
|
+
},
|
|
1180
|
+
X,
|
|
1181
|
+
y,
|
|
1182
|
+
sample_weight=sample_weight,
|
|
1183
|
+
)
|
|
1184
|
+
|
|
1122
1185
|
fit.__doc__ = sklearn_ForestRegressor.fit.__doc__
|
|
1123
1186
|
predict.__doc__ = sklearn_ForestRegressor.predict.__doc__
|
|
1187
|
+
score.__doc__ = sklearn_ForestRegressor.score.__doc__
|
|
1124
1188
|
|
|
1125
1189
|
|
|
1126
1190
|
@control_n_jobs(decorated_methods=["fit", "predict", "predict_proba", "score"])
|
|
@@ -14,6 +14,7 @@
|
|
|
14
14
|
# limitations under the License.
|
|
15
15
|
# ===============================================================================
|
|
16
16
|
|
|
17
|
+
import numpy as np
|
|
17
18
|
import pytest
|
|
18
19
|
from numpy.testing import assert_allclose
|
|
19
20
|
from sklearn.datasets import make_classification, make_regression
|
|
@@ -47,6 +48,8 @@ def test_sklearnex_import_rf_classifier(dataframe, queue):
|
|
|
47
48
|
|
|
48
49
|
@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
|
|
49
50
|
def test_sklearnex_import_rf_regression(dataframe, queue):
|
|
51
|
+
if queue and queue.sycl_device.is_gpu:
|
|
52
|
+
pytest.skip("RF regressor predict for the GPU sycl_queue is buggy.")
|
|
50
53
|
from sklearnex.ensemble import RandomForestRegressor
|
|
51
54
|
|
|
52
55
|
X, y = make_regression(n_features=4, n_informative=2, random_state=0, shuffle=False)
|
|
@@ -67,6 +70,8 @@ def test_sklearnex_import_rf_regression(dataframe, queue):
|
|
|
67
70
|
|
|
68
71
|
@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
|
|
69
72
|
def test_sklearnex_import_et_classifier(dataframe, queue):
|
|
73
|
+
if queue and queue.sycl_device.is_gpu:
|
|
74
|
+
pytest.skip("ET classifier predict for the GPU sycl_queue is buggy.")
|
|
70
75
|
from sklearnex.ensemble import ExtraTreesClassifier
|
|
71
76
|
|
|
72
77
|
X, y = make_classification(
|
|
@@ -88,6 +93,8 @@ def test_sklearnex_import_et_classifier(dataframe, queue):
|
|
|
88
93
|
|
|
89
94
|
@pytest.mark.parametrize("dataframe,queue", get_dataframes_and_queues())
|
|
90
95
|
def test_sklearnex_import_et_regression(dataframe, queue):
|
|
96
|
+
if queue and queue.sycl_device.is_gpu:
|
|
97
|
+
pytest.skip("ET regressor predict for the GPU sycl_queue is buggy.")
|
|
91
98
|
from sklearnex.ensemble import ExtraTreesRegressor
|
|
92
99
|
|
|
93
100
|
X, y = make_regression(n_features=1, random_state=0, shuffle=False)
|
|
@@ -17,18 +17,32 @@
|
|
|
17
17
|
|
|
18
18
|
def get_patch_str(name=None, verbose=True):
|
|
19
19
|
return f"""try:
|
|
20
|
+
# TEMP. FIX: sklearnex.patch_sklearn imports sklearn beforehand
|
|
21
|
+
# when it didn't initialized _threadpool_controller required for
|
|
22
|
+
# pairwise distances dispatching during imports.
|
|
23
|
+
# Manually setting and deleting _threadpool_controller during patch fixes it.
|
|
24
|
+
import sklearn
|
|
25
|
+
from threadpoolctl import ThreadpoolController
|
|
26
|
+
sklearn._threadpool_controller = ThreadpoolController()
|
|
20
27
|
from sklearnex import patch_sklearn
|
|
21
28
|
patch_sklearn(name={str(name)}, verbose={str(verbose)})
|
|
22
|
-
del patch_sklearn
|
|
29
|
+
del patch_sklearn, sklearn._threadpool_controller
|
|
23
30
|
except ImportError:
|
|
24
31
|
pass"""
|
|
25
32
|
|
|
26
33
|
|
|
27
34
|
def get_patch_str_re():
|
|
28
35
|
return r"""\ntry:
|
|
36
|
+
\# TEMP. FIX: sklearnex.patch_sklearn imports sklearn beforehand
|
|
37
|
+
\# when it didn't initialized _threadpool_controller required for
|
|
38
|
+
\# pairwise distances dispatching during imports.
|
|
39
|
+
\# Manually setting and deleting _threadpool_controller during patch fixes it.
|
|
40
|
+
import sklearn
|
|
41
|
+
from threadpoolctl import ThreadpoolController
|
|
42
|
+
sklearn._threadpool_controller = ThreadpoolController\(\)
|
|
29
43
|
from sklearnex import patch_sklearn
|
|
30
44
|
patch_sklearn\(name=.*, verbose=.*\)
|
|
31
|
-
del patch_sklearn
|
|
45
|
+
del patch_sklearn, sklearn._threadpool_controller
|
|
32
46
|
except ImportError:
|
|
33
47
|
pass\n"""
|
|
34
48
|
|
|
@@ -15,3 +15,16 @@
|
|
|
15
15
|
# ===============================================================================
|
|
16
16
|
|
|
17
17
|
from daal4py.sklearn.linear_model import ElasticNet, Lasso
|
|
18
|
+
from onedal._device_offload import support_usm_ndarray
|
|
19
|
+
|
|
20
|
+
# Note: `sklearnex.linear_model.ElasticNet` only has functional
|
|
21
|
+
# sycl GPU support. No GPU device will be offloaded.
|
|
22
|
+
ElasticNet.fit = support_usm_ndarray(queue_param=False)(ElasticNet.fit)
|
|
23
|
+
ElasticNet.predict = support_usm_ndarray(queue_param=False)(ElasticNet.predict)
|
|
24
|
+
ElasticNet.score = support_usm_ndarray(queue_param=False)(ElasticNet.score)
|
|
25
|
+
|
|
26
|
+
# Note: `sklearnex.linear_model.Lasso` only has functional
|
|
27
|
+
# sycl GPU support. No GPU device will be offloaded.
|
|
28
|
+
Lasso.fit = support_usm_ndarray(queue_param=False)(Lasso.fit)
|
|
29
|
+
Lasso.predict = support_usm_ndarray(queue_param=False)(Lasso.predict)
|
|
30
|
+
Lasso.score = support_usm_ndarray(queue_param=False)(Lasso.score)
|
|
@@ -20,6 +20,7 @@ import warnings
|
|
|
20
20
|
import numpy as np
|
|
21
21
|
from sklearn.base import BaseEstimator, MultiOutputMixin, RegressorMixin
|
|
22
22
|
from sklearn.exceptions import NotFittedError
|
|
23
|
+
from sklearn.metrics import r2_score
|
|
23
24
|
from sklearn.utils import check_array, gen_batches
|
|
24
25
|
|
|
25
26
|
from daal4py.sklearn._n_jobs_support import control_n_jobs
|
|
@@ -134,6 +135,7 @@ class IncrementalLinearRegression(MultiOutputMixin, RegressorMixin, BaseEstimato
|
|
|
134
135
|
X,
|
|
135
136
|
dtype=[np.float64, np.float32],
|
|
136
137
|
copy=self.copy_X,
|
|
138
|
+
reset=False,
|
|
137
139
|
)
|
|
138
140
|
else:
|
|
139
141
|
X = check_array(
|
|
@@ -147,33 +149,42 @@ class IncrementalLinearRegression(MultiOutputMixin, RegressorMixin, BaseEstimato
|
|
|
147
149
|
self._onedal_finalize_fit()
|
|
148
150
|
return self._onedal_estimator.predict(X, queue)
|
|
149
151
|
|
|
150
|
-
def
|
|
152
|
+
def _onedal_score(self, X, y, sample_weight=None, queue=None):
|
|
153
|
+
return r2_score(
|
|
154
|
+
y, self._onedal_predict(X, queue=queue), sample_weight=sample_weight
|
|
155
|
+
)
|
|
156
|
+
|
|
157
|
+
def _onedal_partial_fit(self, X, y, check_input=True, queue=None):
|
|
151
158
|
first_pass = not hasattr(self, "n_samples_seen_") or self.n_samples_seen_ == 0
|
|
152
159
|
|
|
153
160
|
if sklearn_check_version("1.2"):
|
|
154
161
|
self._validate_params()
|
|
155
162
|
|
|
156
|
-
if
|
|
157
|
-
|
|
158
|
-
X,
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
163
|
+
if check_input:
|
|
164
|
+
if sklearn_check_version("1.0"):
|
|
165
|
+
X, y = self._validate_data(
|
|
166
|
+
X,
|
|
167
|
+
y,
|
|
168
|
+
dtype=[np.float64, np.float32],
|
|
169
|
+
reset=first_pass,
|
|
170
|
+
copy=self.copy_X,
|
|
171
|
+
multi_output=True,
|
|
172
|
+
force_all_finite=False,
|
|
173
|
+
)
|
|
174
|
+
else:
|
|
175
|
+
X = check_array(
|
|
176
|
+
X,
|
|
177
|
+
dtype=[np.float64, np.float32],
|
|
178
|
+
copy=self.copy_X,
|
|
179
|
+
force_all_finite=False,
|
|
180
|
+
)
|
|
181
|
+
y = check_array(
|
|
182
|
+
y,
|
|
183
|
+
dtype=[np.float64, np.float32],
|
|
184
|
+
copy=False,
|
|
185
|
+
ensure_2d=False,
|
|
186
|
+
force_all_finite=False,
|
|
187
|
+
)
|
|
177
188
|
|
|
178
189
|
if first_pass:
|
|
179
190
|
self.n_samples_seen_ = X.shape[0]
|
|
@@ -202,7 +213,12 @@ class IncrementalLinearRegression(MultiOutputMixin, RegressorMixin, BaseEstimato
|
|
|
202
213
|
|
|
203
214
|
if sklearn_check_version("1.0"):
|
|
204
215
|
X, y = self._validate_data(
|
|
205
|
-
X,
|
|
216
|
+
X,
|
|
217
|
+
y,
|
|
218
|
+
dtype=[np.float64, np.float32],
|
|
219
|
+
copy=self.copy_X,
|
|
220
|
+
multi_output=True,
|
|
221
|
+
ensure_2d=True,
|
|
206
222
|
)
|
|
207
223
|
else:
|
|
208
224
|
X = check_array(
|
|
@@ -234,7 +250,7 @@ class IncrementalLinearRegression(MultiOutputMixin, RegressorMixin, BaseEstimato
|
|
|
234
250
|
|
|
235
251
|
for batch in gen_batches(n_samples, self.batch_size_):
|
|
236
252
|
X_batch, y_batch = X[batch], y[batch]
|
|
237
|
-
self._onedal_partial_fit(X_batch, y_batch, queue=queue)
|
|
253
|
+
self._onedal_partial_fit(X_batch, y_batch, check_input=False, queue=queue)
|
|
238
254
|
|
|
239
255
|
if sklearn_check_version("1.2"):
|
|
240
256
|
self._validate_params()
|
|
@@ -288,7 +304,7 @@ class IncrementalLinearRegression(MultiOutputMixin, RegressorMixin, BaseEstimato
|
|
|
288
304
|
coef_ = property(get_coef_, set_coef_)
|
|
289
305
|
intercept_ = property(get_intercept_, set_intercept_)
|
|
290
306
|
|
|
291
|
-
def partial_fit(self, X, y):
|
|
307
|
+
def partial_fit(self, X, y, check_input=True):
|
|
292
308
|
"""
|
|
293
309
|
Incremental fit linear model with X and y. All of X and y is
|
|
294
310
|
processed as a single batch.
|
|
@@ -318,6 +334,7 @@ class IncrementalLinearRegression(MultiOutputMixin, RegressorMixin, BaseEstimato
|
|
|
318
334
|
},
|
|
319
335
|
X,
|
|
320
336
|
y,
|
|
337
|
+
check_input=check_input,
|
|
321
338
|
)
|
|
322
339
|
return self
|
|
323
340
|
|
|
@@ -385,3 +402,63 @@ class IncrementalLinearRegression(MultiOutputMixin, RegressorMixin, BaseEstimato
|
|
|
385
402
|
},
|
|
386
403
|
X,
|
|
387
404
|
)
|
|
405
|
+
|
|
406
|
+
@wrap_output_data
|
|
407
|
+
def score(self, X, y, sample_weight=None):
|
|
408
|
+
"""Return the coefficient of determination of the prediction.
|
|
409
|
+
|
|
410
|
+
The coefficient of determination :math:`R^2` is defined as
|
|
411
|
+
:math:`(1 - \\frac{u}{v})`, where :math:`u` is the residual
|
|
412
|
+
sum of squares ``((y_true - y_pred)** 2).sum()`` and :math:`v`
|
|
413
|
+
is the total sum of squares ``((y_true - y_true.mean()) ** 2).sum()``.
|
|
414
|
+
The best possible score is 1.0 and it can be negative (because the
|
|
415
|
+
model can be arbitrarily worse). A constant model that always predicts
|
|
416
|
+
the expected value of `y`, disregarding the input features, would get
|
|
417
|
+
a :math:`R^2` score of 0.0.
|
|
418
|
+
|
|
419
|
+
Parameters
|
|
420
|
+
----------
|
|
421
|
+
X : array-like of shape (n_samples, n_features)
|
|
422
|
+
Test samples. For some estimators this may be a precomputed
|
|
423
|
+
kernel matrix or a list of generic objects instead with shape
|
|
424
|
+
``(n_samples, n_samples_fitted)``, where ``n_samples_fitted``
|
|
425
|
+
is the number of samples used in the fitting for the estimator.
|
|
426
|
+
|
|
427
|
+
y : array-like of shape (n_samples,) or (n_samples, n_outputs)
|
|
428
|
+
True values for `X`.
|
|
429
|
+
|
|
430
|
+
sample_weight : array-like of shape (n_samples,), default=None
|
|
431
|
+
Sample weights.
|
|
432
|
+
|
|
433
|
+
Returns
|
|
434
|
+
-------
|
|
435
|
+
score : float
|
|
436
|
+
:math:`R^2` of ``self.predict(X)`` w.r.t. `y`.
|
|
437
|
+
|
|
438
|
+
Notes
|
|
439
|
+
-----
|
|
440
|
+
The :math:`R^2` score used when calling ``score`` on a regressor uses
|
|
441
|
+
``multioutput='uniform_average'`` from version 0.23 to keep consistent
|
|
442
|
+
with default value of :func:`~sklearn.metrics.r2_score`.
|
|
443
|
+
This influences the ``score`` method of all the multioutput
|
|
444
|
+
regressors (except for
|
|
445
|
+
:class:`~sklearn.multioutput.MultiOutputRegressor`).
|
|
446
|
+
"""
|
|
447
|
+
if not hasattr(self, "coef_"):
|
|
448
|
+
msg = (
|
|
449
|
+
"This %(name)s instance is not fitted yet. Call 'fit' or 'partial_fit' "
|
|
450
|
+
"with appropriate arguments before using this estimator."
|
|
451
|
+
)
|
|
452
|
+
raise NotFittedError(msg % {"name": self.__class__.__name__})
|
|
453
|
+
|
|
454
|
+
return dispatch(
|
|
455
|
+
self,
|
|
456
|
+
"score",
|
|
457
|
+
{
|
|
458
|
+
"onedal": self.__class__._onedal_score,
|
|
459
|
+
"sklearn": None,
|
|
460
|
+
},
|
|
461
|
+
X,
|
|
462
|
+
y,
|
|
463
|
+
sample_weight=sample_weight,
|
|
464
|
+
)
|