scikit-learn-intelex 2024.4.0__py311-none-win_amd64.whl → 2024.6.0__py311-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.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/_device_offload.py +8 -1
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/basic_statistics/tests/test_incremental_basic_statistics.py +2 -4
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/cluster/dbscan.py +3 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/cluster/tests/test_dbscan.py +8 -6
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/conftest.py +11 -1
- scikit_learn_intelex-2024.6.0.data/data/Lib/site-packages/sklearnex/covariance/incremental_covariance.py +317 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/covariance/tests/test_incremental_covariance.py +54 -17
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/decomposition/pca.py +68 -13
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/decomposition/tests/test_pca.py +6 -4
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/dispatcher.py +46 -1
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/ensemble/_forest.py +114 -22
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/ensemble/tests/test_forest.py +13 -3
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/glob/dispatcher.py +16 -2
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/linear_model/__init__.py +5 -3
- scikit_learn_intelex-2024.6.0.data/data/Lib/site-packages/sklearnex/linear_model/incremental_linear.py +464 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/linear_model/linear.py +27 -9
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/linear_model/logistic_regression.py +13 -15
- scikit_learn_intelex-2024.6.0.data/data/Lib/site-packages/sklearnex/linear_model/tests/test_incremental_linear.py +200 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/linear_model/tests/test_linear.py +2 -2
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/neighbors/knn_regression.py +24 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/neighbors/tests/test_neighbors.py +2 -2
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/preview/__init__.py +1 -1
- scikit_learn_intelex-2024.6.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/__init__.py +19 -0
- scikit_learn_intelex-2024.6.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/incremental_pca.py +228 -0
- scikit_learn_intelex-2024.6.0.data/data/Lib/site-packages/sklearnex/preview/decomposition/tests/test_incremental_pca.py +266 -0
- scikit_learn_intelex-2024.6.0.data/data/Lib/site-packages/sklearnex/svm/_common.py +330 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/svm/nusvc.py +40 -4
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/svm/nusvr.py +31 -2
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/svm/svc.py +40 -4
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/svm/svr.py +31 -2
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/tests/_utils.py +70 -29
- scikit_learn_intelex-2024.6.0.data/data/Lib/site-packages/sklearnex/tests/test_common.py +54 -0
- scikit_learn_intelex-2024.6.0.data/data/Lib/site-packages/sklearnex/tests/test_memory_usage.py +290 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/tests/test_n_jobs_support.py +4 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/tests/test_patching.py +22 -10
- scikit_learn_intelex-2024.6.0.data/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability.py +283 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/utils/_namespace.py +1 -1
- scikit_learn_intelex-2024.6.0.data/data/Lib/site-packages/sklearnex/utils/tests/test_finite.py +89 -0
- {scikit_learn_intelex-2024.4.0.dist-info → scikit_learn_intelex-2024.6.0.dist-info}/METADATA +230 -230
- scikit_learn_intelex-2024.6.0.dist-info/RECORD +108 -0
- {scikit_learn_intelex-2024.4.0.dist-info → scikit_learn_intelex-2024.6.0.dist-info}/WHEEL +1 -1
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/covariance/incremental_covariance.py +0 -130
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/svm/_common.py +0 -185
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/tests/test_memory_usage.py +0 -227
- scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/tests/test_run_to_run_stability_tests.py +0 -428
- scikit_learn_intelex-2024.4.0.dist-info/RECORD +0 -101
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/__main__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/_config.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/_utils.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/basic_statistics/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/basic_statistics/basic_statistics.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/basic_statistics/incremental_basic_statistics.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/cluster/k_means.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/cluster/tests/test_kmeans.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/covariance/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/decomposition/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/doc/third-party-programs.txt +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/ensemble/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/glob/__main__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/linear_model/coordinate_descent.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/linear_model/logistic_path.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/linear_model/ridge.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/linear_model/tests/test_logreg.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/manifold/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/manifold/t_sne.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/manifold/tests/test_tsne.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/metrics/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/metrics/pairwise.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/metrics/ranking.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/metrics/tests/test_metrics.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/model_selection/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/model_selection/split.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/model_selection/tests/test_model_selection.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/neighbors/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/neighbors/_lof.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/neighbors/common.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/neighbors/knn_classification.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/neighbors/knn_unsupervised.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/_common.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/preview/cluster/k_means.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/covariance.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/preview/covariance/tests/test_covariance.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/basic_statistics/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/basic_statistics/basic_statistics.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/dbscan.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/cluster/kmeans.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/covariance/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/covariance/covariance.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/decomposition/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/decomposition/pca.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/ensemble/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/ensemble/forest.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/linear_model.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/linear_model/logistic_regression.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/neighbors/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/spmd/neighbors/neighbors.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/svm/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/svm/tests/test_svm.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/tests/test_config.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/tests/test_monkeypatch.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/tests/test_parallel.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/utils/__init__.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/utils/parallel.py +0 -0
- {scikit_learn_intelex-2024.4.0.data → scikit_learn_intelex-2024.6.0.data}/data/Lib/site-packages/sklearnex/utils/validation.py +0 -0
- {scikit_learn_intelex-2024.4.0.dist-info → scikit_learn_intelex-2024.6.0.dist-info}/LICENSE.txt +0 -0
- {scikit_learn_intelex-2024.4.0.dist-info → scikit_learn_intelex-2024.6.0.dist-info}/top_level.txt +0 -0
|
@@ -1,130 +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
|
-
import numpy as np
|
|
18
|
-
from sklearn.utils import check_array, gen_batches
|
|
19
|
-
|
|
20
|
-
from daal4py.sklearn._n_jobs_support import control_n_jobs
|
|
21
|
-
from onedal._device_offload import support_usm_ndarray
|
|
22
|
-
from onedal.covariance import (
|
|
23
|
-
IncrementalEmpiricalCovariance as onedal_IncrementalEmpiricalCovariance,
|
|
24
|
-
)
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
@control_n_jobs(decorated_methods=["partial_fit"])
|
|
28
|
-
class IncrementalEmpiricalCovariance:
|
|
29
|
-
"""
|
|
30
|
-
Incremental estimator for covariance.
|
|
31
|
-
Allows to compute empirical covariance estimated by maximum
|
|
32
|
-
likelihood method if data are splitted into batches.
|
|
33
|
-
|
|
34
|
-
Parameters
|
|
35
|
-
----------
|
|
36
|
-
batch_size : int, default=None
|
|
37
|
-
The number of samples to use for each batch. Only used when calling
|
|
38
|
-
``fit``. If ``batch_size`` is ``None``, then ``batch_size``
|
|
39
|
-
is inferred from the data and set to ``5 * n_features``, to provide a
|
|
40
|
-
balance between approximation accuracy and memory consumption.
|
|
41
|
-
|
|
42
|
-
Attributes
|
|
43
|
-
----------
|
|
44
|
-
location_ : ndarray of shape (n_features,)
|
|
45
|
-
Estimated location, i.e. the estimated mean.
|
|
46
|
-
|
|
47
|
-
covariance_ : ndarray of shape (n_features, n_features)
|
|
48
|
-
Estimated covariance matrix
|
|
49
|
-
"""
|
|
50
|
-
|
|
51
|
-
_onedal_incremental_covariance = staticmethod(onedal_IncrementalEmpiricalCovariance)
|
|
52
|
-
|
|
53
|
-
def __init__(self, batch_size=None):
|
|
54
|
-
self._need_to_finalize = False # If True then finalize compute should
|
|
55
|
-
# be called to obtain covariance_ or location_ from partial compute data
|
|
56
|
-
self.batch_size = batch_size
|
|
57
|
-
|
|
58
|
-
def _onedal_finalize_fit(self):
|
|
59
|
-
assert hasattr(self, "_onedal_estimator")
|
|
60
|
-
self._onedal_estimator.finalize_fit()
|
|
61
|
-
self._need_to_finalize = False
|
|
62
|
-
|
|
63
|
-
def _onedal_partial_fit(self, X, queue):
|
|
64
|
-
onedal_params = {
|
|
65
|
-
"method": "dense",
|
|
66
|
-
"bias": True,
|
|
67
|
-
}
|
|
68
|
-
if not hasattr(self, "_onedal_estimator"):
|
|
69
|
-
self._onedal_estimator = self._onedal_incremental_covariance(**onedal_params)
|
|
70
|
-
self._onedal_estimator.partial_fit(X, queue)
|
|
71
|
-
self._need_to_finalize = True
|
|
72
|
-
|
|
73
|
-
@property
|
|
74
|
-
def covariance_(self):
|
|
75
|
-
if self._need_to_finalize:
|
|
76
|
-
self._onedal_finalize_fit()
|
|
77
|
-
return self._onedal_estimator.covariance_
|
|
78
|
-
|
|
79
|
-
@property
|
|
80
|
-
def location_(self):
|
|
81
|
-
if self._need_to_finalize:
|
|
82
|
-
self._onedal_finalize_fit()
|
|
83
|
-
return self._onedal_estimator.location_
|
|
84
|
-
|
|
85
|
-
@support_usm_ndarray()
|
|
86
|
-
def partial_fit(self, X, queue=None):
|
|
87
|
-
"""
|
|
88
|
-
Incremental fit with X. All of X is processed as a single batch.
|
|
89
|
-
|
|
90
|
-
Parameters
|
|
91
|
-
----------
|
|
92
|
-
X : array-like of shape (n_samples, n_features)
|
|
93
|
-
Training data, where `n_samples` is the number of samples and
|
|
94
|
-
`n_features` is the number of features.
|
|
95
|
-
|
|
96
|
-
Returns
|
|
97
|
-
-------
|
|
98
|
-
self : object
|
|
99
|
-
Returns the instance itself.
|
|
100
|
-
"""
|
|
101
|
-
X = check_array(X, dtype=[np.float64, np.float32])
|
|
102
|
-
self._onedal_partial_fit(X, queue)
|
|
103
|
-
return self
|
|
104
|
-
|
|
105
|
-
def fit(self, X, queue=None):
|
|
106
|
-
"""
|
|
107
|
-
Fit the model with X, using minibatches of size batch_size.
|
|
108
|
-
|
|
109
|
-
Parameters
|
|
110
|
-
----------
|
|
111
|
-
X : array-like of shape (n_samples, n_features)
|
|
112
|
-
Training data, where `n_samples` is the number of samples and
|
|
113
|
-
`n_features` is the number of features.
|
|
114
|
-
|
|
115
|
-
Returns
|
|
116
|
-
-------
|
|
117
|
-
self : object
|
|
118
|
-
Returns the instance itself.
|
|
119
|
-
"""
|
|
120
|
-
n_samples, n_features = X.shape
|
|
121
|
-
if self.batch_size is None:
|
|
122
|
-
batch_size_ = 5 * n_features
|
|
123
|
-
else:
|
|
124
|
-
batch_size_ = self.batch_size
|
|
125
|
-
for batch in gen_batches(n_samples, batch_size_):
|
|
126
|
-
X_batch = X[batch]
|
|
127
|
-
self.partial_fit(X_batch, queue=queue)
|
|
128
|
-
|
|
129
|
-
self._onedal_finalize_fit()
|
|
130
|
-
return self
|
|
@@ -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_
|
scikit_learn_intelex-2024.4.0.data/data/Lib/site-packages/sklearnex/tests/test_memory_usage.py
DELETED
|
@@ -1,227 +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
|
-
|
|
18
|
-
import gc
|
|
19
|
-
import logging
|
|
20
|
-
import tracemalloc
|
|
21
|
-
import types
|
|
22
|
-
|
|
23
|
-
import numpy as np
|
|
24
|
-
import pandas as pd
|
|
25
|
-
import pytest
|
|
26
|
-
from scipy.stats import pearsonr
|
|
27
|
-
from sklearn.base import BaseEstimator
|
|
28
|
-
from sklearn.datasets import make_classification
|
|
29
|
-
from sklearn.model_selection import KFold
|
|
30
|
-
|
|
31
|
-
from sklearnex import get_patch_map
|
|
32
|
-
from sklearnex.metrics import pairwise_distances, roc_auc_score
|
|
33
|
-
from sklearnex.model_selection import train_test_split
|
|
34
|
-
from sklearnex.utils import _assert_all_finite
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
class TrainTestSplitEstimator:
|
|
38
|
-
def __init__(self):
|
|
39
|
-
pass
|
|
40
|
-
|
|
41
|
-
def fit(self, x, y):
|
|
42
|
-
train_test_split(x, y)
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
class FiniteCheckEstimator:
|
|
46
|
-
def __init__(self):
|
|
47
|
-
pass
|
|
48
|
-
|
|
49
|
-
def fit(self, x, y):
|
|
50
|
-
_assert_all_finite(x)
|
|
51
|
-
_assert_all_finite(y)
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
class PairwiseDistancesEstimator:
|
|
55
|
-
def fit(self, x, y):
|
|
56
|
-
pairwise_distances(x, metric=self.metric)
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
class CosineDistancesEstimator(PairwiseDistancesEstimator):
|
|
60
|
-
def __init__(self):
|
|
61
|
-
self.metric = "cosine"
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
class CorrelationDistancesEstimator(PairwiseDistancesEstimator):
|
|
65
|
-
def __init__(self):
|
|
66
|
-
self.metric = "correlation"
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
class RocAucEstimator:
|
|
70
|
-
def __init__(self):
|
|
71
|
-
pass
|
|
72
|
-
|
|
73
|
-
def fit(self, x, y):
|
|
74
|
-
print(roc_auc_score(y, np.zeros(shape=y.shape, dtype=np.int32)))
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
# add all daal4py estimators enabled in patching (except banned)
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
def get_patched_estimators(ban_list, output_list):
|
|
81
|
-
patched_estimators = get_patch_map().values()
|
|
82
|
-
for listing in patched_estimators:
|
|
83
|
-
estimator, name = listing[0][0][2], listing[0][0][1]
|
|
84
|
-
if not isinstance(estimator, types.FunctionType):
|
|
85
|
-
if name not in ban_list:
|
|
86
|
-
if issubclass(estimator, BaseEstimator):
|
|
87
|
-
if hasattr(estimator, "fit"):
|
|
88
|
-
output_list.append(estimator)
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
def remove_duplicated_estimators(estimators_list):
|
|
92
|
-
estimators_map = {}
|
|
93
|
-
for estimator in estimators_list:
|
|
94
|
-
full_name = f"{estimator.__module__}.{estimator.__name__}"
|
|
95
|
-
estimators_map[full_name] = estimator
|
|
96
|
-
return estimators_map.values()
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
BANNED_ESTIMATORS = ("TSNE",) # too slow for using in testing on common data size
|
|
100
|
-
estimators = [
|
|
101
|
-
TrainTestSplitEstimator,
|
|
102
|
-
FiniteCheckEstimator,
|
|
103
|
-
CosineDistancesEstimator,
|
|
104
|
-
CorrelationDistancesEstimator,
|
|
105
|
-
RocAucEstimator,
|
|
106
|
-
]
|
|
107
|
-
get_patched_estimators(BANNED_ESTIMATORS, estimators)
|
|
108
|
-
estimators = remove_duplicated_estimators(estimators)
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
def ndarray_c(x, y):
|
|
112
|
-
return np.ascontiguousarray(x), y
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
def ndarray_f(x, y):
|
|
116
|
-
return np.asfortranarray(x), y
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
def dataframe_c(x, y):
|
|
120
|
-
return pd.DataFrame(np.ascontiguousarray(x)), pd.Series(y)
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
def dataframe_f(x, y):
|
|
124
|
-
return pd.DataFrame(np.asfortranarray(x)), pd.Series(y)
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
data_transforms = [ndarray_c, ndarray_f, dataframe_c, dataframe_f]
|
|
128
|
-
|
|
129
|
-
data_shapes = [(1000, 100), (2000, 50)]
|
|
130
|
-
|
|
131
|
-
EXTRA_MEMORY_THRESHOLD = 0.15
|
|
132
|
-
N_SPLITS = 10
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
def gen_clsf_data(n_samples, n_features):
|
|
136
|
-
data, label = make_classification(
|
|
137
|
-
n_classes=2, n_samples=n_samples, n_features=n_features, random_state=777
|
|
138
|
-
)
|
|
139
|
-
return (
|
|
140
|
-
data,
|
|
141
|
-
label,
|
|
142
|
-
data.size * data.dtype.itemsize + label.size * label.dtype.itemsize,
|
|
143
|
-
)
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
def split_train_inference(kf, x, y, estimator):
|
|
147
|
-
mem_tracks = []
|
|
148
|
-
for train_index, test_index in kf.split(x):
|
|
149
|
-
if isinstance(x, np.ndarray):
|
|
150
|
-
x_train, x_test = x[train_index], x[test_index]
|
|
151
|
-
y_train, y_test = y[train_index], y[test_index]
|
|
152
|
-
elif isinstance(x, pd.core.frame.DataFrame):
|
|
153
|
-
x_train, x_test = x.iloc[train_index], x.iloc[test_index]
|
|
154
|
-
y_train, y_test = y.iloc[train_index], y.iloc[test_index]
|
|
155
|
-
# TODO: add parameters for all estimators to prevent
|
|
156
|
-
# fallback to stock scikit-learn with default parameters
|
|
157
|
-
|
|
158
|
-
alg = estimator()
|
|
159
|
-
alg.fit(x_train, y_train)
|
|
160
|
-
if hasattr(alg, "predict"):
|
|
161
|
-
alg.predict(x_test)
|
|
162
|
-
elif hasattr(alg, "transform"):
|
|
163
|
-
alg.transform(x_test)
|
|
164
|
-
elif hasattr(alg, "kneighbors"):
|
|
165
|
-
alg.kneighbors(x_test)
|
|
166
|
-
del alg, x_train, x_test, y_train, y_test
|
|
167
|
-
mem_tracks.append(tracemalloc.get_traced_memory()[0])
|
|
168
|
-
return mem_tracks
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
def _kfold_function_template(estimator, data_transform_function, data_shape):
|
|
172
|
-
tracemalloc.start()
|
|
173
|
-
|
|
174
|
-
n_samples, n_features = data_shape
|
|
175
|
-
x, y, data_memory_size = gen_clsf_data(n_samples, n_features)
|
|
176
|
-
kf = KFold(n_splits=N_SPLITS)
|
|
177
|
-
x, y = data_transform_function(x, y)
|
|
178
|
-
|
|
179
|
-
mem_before, _ = tracemalloc.get_traced_memory()
|
|
180
|
-
mem_tracks = split_train_inference(kf, x, y, estimator)
|
|
181
|
-
mem_iter_diffs = np.array(mem_tracks[1:]) - np.array(mem_tracks[:-1])
|
|
182
|
-
mem_incr_mean, mem_incr_std = mem_iter_diffs.mean(), mem_iter_diffs.std()
|
|
183
|
-
mem_incr_mean, mem_incr_std = round(mem_incr_mean), round(mem_incr_std)
|
|
184
|
-
mem_iter_corr, _ = pearsonr(mem_tracks, list(range(len(mem_tracks))))
|
|
185
|
-
if mem_iter_corr > 0.95:
|
|
186
|
-
logging.warning(
|
|
187
|
-
"Memory usage is steadily increasing with iterations "
|
|
188
|
-
"(Pearson correlation coefficient between "
|
|
189
|
-
f"memory tracks and iterations is {mem_iter_corr})\n"
|
|
190
|
-
"Memory usage increase per iteration: "
|
|
191
|
-
f"{mem_incr_mean}±{mem_incr_std} bytes"
|
|
192
|
-
)
|
|
193
|
-
mem_before_gc, _ = tracemalloc.get_traced_memory()
|
|
194
|
-
mem_diff = mem_before_gc - mem_before
|
|
195
|
-
message = (
|
|
196
|
-
"Size of extra allocated memory {} using garbage collector "
|
|
197
|
-
f"is greater than {EXTRA_MEMORY_THRESHOLD * 100}% of input data"
|
|
198
|
-
f"\n\tAlgorithm: {estimator.__name__}"
|
|
199
|
-
f"\n\tInput data size: {data_memory_size} bytes"
|
|
200
|
-
"\n\tExtra allocated memory size: {} bytes"
|
|
201
|
-
" / {} %"
|
|
202
|
-
)
|
|
203
|
-
if mem_diff >= EXTRA_MEMORY_THRESHOLD * data_memory_size:
|
|
204
|
-
logging.warning(
|
|
205
|
-
message.format(
|
|
206
|
-
"before", mem_diff, round((mem_diff) / data_memory_size * 100, 2)
|
|
207
|
-
)
|
|
208
|
-
)
|
|
209
|
-
gc.collect()
|
|
210
|
-
mem_after, _ = tracemalloc.get_traced_memory()
|
|
211
|
-
tracemalloc.stop()
|
|
212
|
-
mem_diff = mem_after - mem_before
|
|
213
|
-
|
|
214
|
-
assert mem_diff < EXTRA_MEMORY_THRESHOLD * data_memory_size, message.format(
|
|
215
|
-
"after", mem_diff, round((mem_diff) / data_memory_size * 100, 2)
|
|
216
|
-
)
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
# disable fallback check as logging impacts memory use
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
@pytest.mark.allow_sklearn_fallback
|
|
223
|
-
@pytest.mark.parametrize("data_transform_function", data_transforms)
|
|
224
|
-
@pytest.mark.parametrize("estimator", estimators)
|
|
225
|
-
@pytest.mark.parametrize("data_shape", data_shapes)
|
|
226
|
-
def test_memory_leaks(estimator, data_transform_function, data_shape):
|
|
227
|
-
_kfold_function_template(estimator, data_transform_function, data_shape)
|