scikit-learn-intelex 2025.1.0__py310-none-manylinux_2_28_x86_64.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.
- daal4py/__init__.py +73 -0
- daal4py/__main__.py +58 -0
- daal4py/_daal4py.cpython-310-x86_64-linux-gnu.so +0 -0
- daal4py/doc/third-party-programs.txt +424 -0
- daal4py/mb/__init__.py +19 -0
- daal4py/mb/model_builders.py +377 -0
- daal4py/mpi_transceiver.cpython-310-x86_64-linux-gnu.so +0 -0
- daal4py/sklearn/__init__.py +40 -0
- daal4py/sklearn/_n_jobs_support.py +248 -0
- daal4py/sklearn/_utils.py +245 -0
- daal4py/sklearn/cluster/__init__.py +20 -0
- daal4py/sklearn/cluster/dbscan.py +165 -0
- daal4py/sklearn/cluster/k_means.py +597 -0
- daal4py/sklearn/cluster/tests/test_dbscan.py +109 -0
- daal4py/sklearn/decomposition/__init__.py +19 -0
- daal4py/sklearn/decomposition/_pca.py +524 -0
- daal4py/sklearn/ensemble/AdaBoostClassifier.py +196 -0
- daal4py/sklearn/ensemble/GBTDAAL.py +337 -0
- daal4py/sklearn/ensemble/__init__.py +27 -0
- daal4py/sklearn/ensemble/_forest.py +1397 -0
- daal4py/sklearn/ensemble/tests/test_decision_forest.py +206 -0
- daal4py/sklearn/linear_model/__init__.py +29 -0
- daal4py/sklearn/linear_model/_coordinate_descent.py +848 -0
- daal4py/sklearn/linear_model/_linear.py +272 -0
- daal4py/sklearn/linear_model/_ridge.py +325 -0
- daal4py/sklearn/linear_model/coordinate_descent.py +17 -0
- daal4py/sklearn/linear_model/linear.py +17 -0
- daal4py/sklearn/linear_model/logistic_loss.py +195 -0
- daal4py/sklearn/linear_model/logistic_path.py +1026 -0
- daal4py/sklearn/linear_model/ridge.py +17 -0
- daal4py/sklearn/linear_model/tests/test_linear.py +208 -0
- daal4py/sklearn/linear_model/tests/test_ridge.py +69 -0
- daal4py/sklearn/manifold/__init__.py +19 -0
- daal4py/sklearn/manifold/_t_sne.py +405 -0
- daal4py/sklearn/metrics/__init__.py +20 -0
- daal4py/sklearn/metrics/_pairwise.py +236 -0
- daal4py/sklearn/metrics/_ranking.py +210 -0
- daal4py/sklearn/model_selection/__init__.py +19 -0
- daal4py/sklearn/model_selection/_split.py +309 -0
- daal4py/sklearn/model_selection/tests/test_split.py +56 -0
- daal4py/sklearn/monkeypatch/__init__.py +0 -0
- daal4py/sklearn/monkeypatch/dispatcher.py +232 -0
- daal4py/sklearn/monkeypatch/tests/_models_info.py +161 -0
- daal4py/sklearn/monkeypatch/tests/test_monkeypatch.py +71 -0
- daal4py/sklearn/monkeypatch/tests/test_patching.py +90 -0
- daal4py/sklearn/monkeypatch/tests/utils/_launch_algorithms.py +117 -0
- daal4py/sklearn/neighbors/__init__.py +21 -0
- daal4py/sklearn/neighbors/_base.py +503 -0
- daal4py/sklearn/neighbors/_classification.py +139 -0
- daal4py/sklearn/neighbors/_regression.py +74 -0
- daal4py/sklearn/neighbors/_unsupervised.py +55 -0
- daal4py/sklearn/neighbors/tests/test_kneighbors.py +113 -0
- daal4py/sklearn/svm/__init__.py +19 -0
- daal4py/sklearn/svm/svm.py +734 -0
- daal4py/sklearn/utils/__init__.py +21 -0
- daal4py/sklearn/utils/base.py +75 -0
- daal4py/sklearn/utils/tests/test_utils.py +51 -0
- daal4py/sklearn/utils/validation.py +693 -0
- onedal/__init__.py +83 -0
- onedal/_config.py +54 -0
- onedal/_device_offload.py +222 -0
- onedal/_onedal_py_dpc.cpython-310-x86_64-linux-gnu.so +0 -0
- onedal/_onedal_py_host.cpython-310-x86_64-linux-gnu.so +0 -0
- onedal/_onedal_py_spmd_dpc.cpython-310-x86_64-linux-gnu.so +0 -0
- onedal/basic_statistics/__init__.py +20 -0
- onedal/basic_statistics/basic_statistics.py +107 -0
- onedal/basic_statistics/incremental_basic_statistics.py +160 -0
- onedal/basic_statistics/tests/test_basic_statistics.py +298 -0
- onedal/basic_statistics/tests/test_incremental_basic_statistics.py +196 -0
- onedal/cluster/__init__.py +27 -0
- onedal/cluster/dbscan.py +110 -0
- onedal/cluster/kmeans.py +564 -0
- onedal/cluster/kmeans_init.py +115 -0
- onedal/cluster/tests/test_dbscan.py +125 -0
- onedal/cluster/tests/test_kmeans.py +88 -0
- onedal/cluster/tests/test_kmeans_init.py +93 -0
- onedal/common/_base.py +38 -0
- onedal/common/_estimator_checks.py +47 -0
- onedal/common/_mixin.py +62 -0
- onedal/common/_policy.py +59 -0
- onedal/common/_spmd_policy.py +30 -0
- onedal/common/hyperparameters.py +125 -0
- onedal/common/tests/test_policy.py +76 -0
- onedal/covariance/__init__.py +20 -0
- onedal/covariance/covariance.py +125 -0
- onedal/covariance/incremental_covariance.py +146 -0
- onedal/covariance/tests/test_covariance.py +50 -0
- onedal/covariance/tests/test_incremental_covariance.py +122 -0
- onedal/datatypes/__init__.py +19 -0
- onedal/datatypes/_data_conversion.py +154 -0
- onedal/datatypes/tests/common.py +126 -0
- onedal/datatypes/tests/test_data.py +414 -0
- onedal/decomposition/__init__.py +20 -0
- onedal/decomposition/incremental_pca.py +204 -0
- onedal/decomposition/pca.py +186 -0
- onedal/decomposition/tests/test_incremental_pca.py +198 -0
- onedal/ensemble/__init__.py +29 -0
- onedal/ensemble/forest.py +727 -0
- onedal/ensemble/tests/test_random_forest.py +97 -0
- onedal/linear_model/__init__.py +27 -0
- onedal/linear_model/incremental_linear_model.py +258 -0
- onedal/linear_model/linear_model.py +329 -0
- onedal/linear_model/logistic_regression.py +249 -0
- onedal/linear_model/tests/test_incremental_linear_regression.py +168 -0
- onedal/linear_model/tests/test_incremental_ridge_regression.py +107 -0
- onedal/linear_model/tests/test_linear_regression.py +250 -0
- onedal/linear_model/tests/test_logistic_regression.py +95 -0
- onedal/linear_model/tests/test_ridge.py +95 -0
- onedal/neighbors/__init__.py +19 -0
- onedal/neighbors/neighbors.py +767 -0
- onedal/neighbors/tests/test_knn_classification.py +49 -0
- onedal/primitives/__init__.py +27 -0
- onedal/primitives/get_tree.py +25 -0
- onedal/primitives/kernel_functions.py +153 -0
- onedal/primitives/tests/test_kernel_functions.py +159 -0
- onedal/spmd/__init__.py +25 -0
- onedal/spmd/_base.py +30 -0
- onedal/spmd/basic_statistics/__init__.py +20 -0
- onedal/spmd/basic_statistics/basic_statistics.py +30 -0
- onedal/spmd/basic_statistics/incremental_basic_statistics.py +69 -0
- onedal/spmd/cluster/__init__.py +28 -0
- onedal/spmd/cluster/dbscan.py +23 -0
- onedal/spmd/cluster/kmeans.py +56 -0
- onedal/spmd/covariance/__init__.py +20 -0
- onedal/spmd/covariance/covariance.py +26 -0
- onedal/spmd/covariance/incremental_covariance.py +82 -0
- onedal/spmd/decomposition/__init__.py +20 -0
- onedal/spmd/decomposition/incremental_pca.py +117 -0
- onedal/spmd/decomposition/pca.py +26 -0
- onedal/spmd/ensemble/__init__.py +19 -0
- onedal/spmd/ensemble/forest.py +28 -0
- onedal/spmd/linear_model/__init__.py +21 -0
- onedal/spmd/linear_model/incremental_linear_model.py +97 -0
- onedal/spmd/linear_model/linear_model.py +30 -0
- onedal/spmd/linear_model/logistic_regression.py +38 -0
- onedal/spmd/neighbors/__init__.py +19 -0
- onedal/spmd/neighbors/neighbors.py +75 -0
- onedal/svm/__init__.py +19 -0
- onedal/svm/svm.py +556 -0
- onedal/svm/tests/test_csr_svm.py +351 -0
- onedal/svm/tests/test_nusvc.py +204 -0
- onedal/svm/tests/test_nusvr.py +210 -0
- onedal/svm/tests/test_svc.py +176 -0
- onedal/svm/tests/test_svr.py +243 -0
- onedal/tests/test_common.py +57 -0
- onedal/tests/utils/_dataframes_support.py +162 -0
- onedal/tests/utils/_device_selection.py +102 -0
- onedal/utils/__init__.py +49 -0
- onedal/utils/_array_api.py +81 -0
- onedal/utils/_dpep_helpers.py +56 -0
- onedal/utils/validation.py +440 -0
- scikit_learn_intelex-2025.1.0.dist-info/LICENSE.txt +202 -0
- scikit_learn_intelex-2025.1.0.dist-info/METADATA +231 -0
- scikit_learn_intelex-2025.1.0.dist-info/RECORD +280 -0
- scikit_learn_intelex-2025.1.0.dist-info/WHEEL +5 -0
- scikit_learn_intelex-2025.1.0.dist-info/top_level.txt +3 -0
- sklearnex/__init__.py +66 -0
- sklearnex/__main__.py +58 -0
- sklearnex/_config.py +116 -0
- sklearnex/_device_offload.py +126 -0
- sklearnex/_utils.py +132 -0
- sklearnex/basic_statistics/__init__.py +20 -0
- sklearnex/basic_statistics/basic_statistics.py +230 -0
- sklearnex/basic_statistics/incremental_basic_statistics.py +345 -0
- sklearnex/basic_statistics/tests/test_basic_statistics.py +270 -0
- sklearnex/basic_statistics/tests/test_incremental_basic_statistics.py +404 -0
- sklearnex/cluster/__init__.py +20 -0
- sklearnex/cluster/dbscan.py +197 -0
- sklearnex/cluster/k_means.py +395 -0
- sklearnex/cluster/tests/test_dbscan.py +38 -0
- sklearnex/cluster/tests/test_kmeans.py +159 -0
- sklearnex/conftest.py +82 -0
- sklearnex/covariance/__init__.py +19 -0
- sklearnex/covariance/incremental_covariance.py +398 -0
- sklearnex/covariance/tests/test_incremental_covariance.py +237 -0
- sklearnex/decomposition/__init__.py +19 -0
- sklearnex/decomposition/pca.py +425 -0
- sklearnex/decomposition/tests/test_pca.py +58 -0
- sklearnex/dispatcher.py +543 -0
- sklearnex/doc/third-party-programs.txt +424 -0
- sklearnex/ensemble/__init__.py +29 -0
- sklearnex/ensemble/_forest.py +2029 -0
- sklearnex/ensemble/tests/test_forest.py +135 -0
- sklearnex/glob/__main__.py +72 -0
- sklearnex/glob/dispatcher.py +101 -0
- sklearnex/linear_model/__init__.py +32 -0
- sklearnex/linear_model/coordinate_descent.py +30 -0
- sklearnex/linear_model/incremental_linear.py +482 -0
- sklearnex/linear_model/incremental_ridge.py +425 -0
- sklearnex/linear_model/linear.py +341 -0
- sklearnex/linear_model/logistic_regression.py +413 -0
- sklearnex/linear_model/ridge.py +24 -0
- sklearnex/linear_model/tests/test_incremental_linear.py +207 -0
- sklearnex/linear_model/tests/test_incremental_ridge.py +153 -0
- sklearnex/linear_model/tests/test_linear.py +167 -0
- sklearnex/linear_model/tests/test_logreg.py +134 -0
- sklearnex/manifold/__init__.py +19 -0
- sklearnex/manifold/t_sne.py +21 -0
- sklearnex/manifold/tests/test_tsne.py +26 -0
- sklearnex/metrics/__init__.py +23 -0
- sklearnex/metrics/pairwise.py +22 -0
- sklearnex/metrics/ranking.py +20 -0
- sklearnex/metrics/tests/test_metrics.py +39 -0
- sklearnex/model_selection/__init__.py +21 -0
- sklearnex/model_selection/split.py +22 -0
- sklearnex/model_selection/tests/test_model_selection.py +34 -0
- sklearnex/neighbors/__init__.py +27 -0
- sklearnex/neighbors/_lof.py +236 -0
- sklearnex/neighbors/common.py +310 -0
- sklearnex/neighbors/knn_classification.py +231 -0
- sklearnex/neighbors/knn_regression.py +207 -0
- sklearnex/neighbors/knn_unsupervised.py +178 -0
- sklearnex/neighbors/tests/test_neighbors.py +82 -0
- sklearnex/preview/__init__.py +17 -0
- sklearnex/preview/covariance/__init__.py +19 -0
- sklearnex/preview/covariance/covariance.py +138 -0
- sklearnex/preview/covariance/tests/test_covariance.py +66 -0
- sklearnex/preview/decomposition/__init__.py +19 -0
- sklearnex/preview/decomposition/incremental_pca.py +233 -0
- sklearnex/preview/decomposition/tests/test_incremental_pca.py +266 -0
- sklearnex/preview/linear_model/__init__.py +19 -0
- sklearnex/preview/linear_model/ridge.py +424 -0
- sklearnex/preview/linear_model/tests/test_ridge.py +102 -0
- sklearnex/spmd/__init__.py +25 -0
- sklearnex/spmd/basic_statistics/__init__.py +20 -0
- sklearnex/spmd/basic_statistics/basic_statistics.py +21 -0
- sklearnex/spmd/basic_statistics/incremental_basic_statistics.py +30 -0
- sklearnex/spmd/basic_statistics/tests/test_basic_statistics_spmd.py +107 -0
- sklearnex/spmd/basic_statistics/tests/test_incremental_basic_statistics_spmd.py +307 -0
- sklearnex/spmd/cluster/__init__.py +30 -0
- sklearnex/spmd/cluster/dbscan.py +50 -0
- sklearnex/spmd/cluster/kmeans.py +21 -0
- sklearnex/spmd/cluster/tests/test_dbscan_spmd.py +97 -0
- sklearnex/spmd/cluster/tests/test_kmeans_spmd.py +172 -0
- sklearnex/spmd/covariance/__init__.py +20 -0
- sklearnex/spmd/covariance/covariance.py +21 -0
- sklearnex/spmd/covariance/incremental_covariance.py +37 -0
- sklearnex/spmd/covariance/tests/test_covariance_spmd.py +107 -0
- sklearnex/spmd/covariance/tests/test_incremental_covariance_spmd.py +184 -0
- sklearnex/spmd/decomposition/__init__.py +20 -0
- sklearnex/spmd/decomposition/incremental_pca.py +30 -0
- sklearnex/spmd/decomposition/pca.py +21 -0
- sklearnex/spmd/decomposition/tests/test_incremental_pca_spmd.py +269 -0
- sklearnex/spmd/decomposition/tests/test_pca_spmd.py +128 -0
- sklearnex/spmd/ensemble/__init__.py +19 -0
- sklearnex/spmd/ensemble/forest.py +71 -0
- sklearnex/spmd/ensemble/tests/test_forest_spmd.py +265 -0
- sklearnex/spmd/linear_model/__init__.py +21 -0
- sklearnex/spmd/linear_model/incremental_linear_model.py +35 -0
- sklearnex/spmd/linear_model/linear_model.py +21 -0
- sklearnex/spmd/linear_model/logistic_regression.py +21 -0
- sklearnex/spmd/linear_model/tests/test_incremental_linear_spmd.py +329 -0
- sklearnex/spmd/linear_model/tests/test_linear_regression_spmd.py +145 -0
- sklearnex/spmd/linear_model/tests/test_logistic_regression_spmd.py +162 -0
- sklearnex/spmd/neighbors/__init__.py +19 -0
- sklearnex/spmd/neighbors/neighbors.py +25 -0
- sklearnex/spmd/neighbors/tests/test_neighbors_spmd.py +288 -0
- sklearnex/svm/__init__.py +29 -0
- sklearnex/svm/_common.py +339 -0
- sklearnex/svm/nusvc.py +371 -0
- sklearnex/svm/nusvr.py +170 -0
- sklearnex/svm/svc.py +399 -0
- sklearnex/svm/svr.py +167 -0
- sklearnex/svm/tests/test_svm.py +93 -0
- sklearnex/tests/test_common.py +390 -0
- sklearnex/tests/test_config.py +123 -0
- sklearnex/tests/test_memory_usage.py +379 -0
- sklearnex/tests/test_monkeypatch.py +276 -0
- sklearnex/tests/test_n_jobs_support.py +108 -0
- sklearnex/tests/test_parallel.py +48 -0
- sklearnex/tests/test_patching.py +385 -0
- sklearnex/tests/test_run_to_run_stability.py +321 -0
- sklearnex/tests/utils/__init__.py +44 -0
- sklearnex/tests/utils/base.py +371 -0
- sklearnex/tests/utils/spmd.py +198 -0
- sklearnex/utils/__init__.py +19 -0
- sklearnex/utils/_array_api.py +82 -0
- sklearnex/utils/parallel.py +59 -0
- sklearnex/utils/tests/test_finite.py +89 -0
- sklearnex/utils/validation.py +17 -0
|
@@ -0,0 +1,440 @@
|
|
|
1
|
+
# ==============================================================================
|
|
2
|
+
# Copyright 2021 Intel Corporation
|
|
3
|
+
#
|
|
4
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
|
5
|
+
# you may not use this file except in compliance with the License.
|
|
6
|
+
# You may obtain a copy of the License at
|
|
7
|
+
#
|
|
8
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
|
9
|
+
#
|
|
10
|
+
# Unless required by applicable law or agreed to in writing, software
|
|
11
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
|
12
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
13
|
+
# See the License for the specific language governing permissions and
|
|
14
|
+
# limitations under the License.
|
|
15
|
+
# ==============================================================================
|
|
16
|
+
|
|
17
|
+
import warnings
|
|
18
|
+
from collections.abc import Sequence
|
|
19
|
+
from numbers import Integral
|
|
20
|
+
|
|
21
|
+
import numpy as np
|
|
22
|
+
from scipy import sparse as sp
|
|
23
|
+
|
|
24
|
+
if np.lib.NumpyVersion(np.__version__) >= np.lib.NumpyVersion("2.0.0a0"):
|
|
25
|
+
# numpy_version >= 2.0
|
|
26
|
+
from numpy.exceptions import VisibleDeprecationWarning
|
|
27
|
+
else:
|
|
28
|
+
# numpy_version < 2.0
|
|
29
|
+
from numpy import VisibleDeprecationWarning
|
|
30
|
+
|
|
31
|
+
from sklearn.preprocessing import LabelEncoder
|
|
32
|
+
from sklearn.utils.validation import check_array
|
|
33
|
+
|
|
34
|
+
from daal4py.sklearn.utils.validation import _assert_all_finite
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
class DataConversionWarning(UserWarning):
|
|
38
|
+
"""Warning used to notify implicit data conversions happening in the code."""
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
def _is_arraylike(x):
|
|
42
|
+
"""Returns whether the input is array-like."""
|
|
43
|
+
return hasattr(x, "__len__") or hasattr(x, "shape") or hasattr(x, "__array__")
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
def _is_arraylike_not_scalar(array):
|
|
47
|
+
"""Return True if array is array-like and not a scalar"""
|
|
48
|
+
return _is_arraylike(array) and not np.isscalar(array)
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
def _column_or_1d(y, warn=False):
|
|
52
|
+
y = np.asarray(y)
|
|
53
|
+
|
|
54
|
+
# TODO: Convert this kind of arrays to a table like in daal4py
|
|
55
|
+
if not y.flags.aligned and not y.flags.writeable:
|
|
56
|
+
y = np.array(y.tolist())
|
|
57
|
+
|
|
58
|
+
shape = np.shape(y)
|
|
59
|
+
if len(shape) == 1:
|
|
60
|
+
return np.ravel(y)
|
|
61
|
+
if len(shape) == 2 and shape[1] == 1:
|
|
62
|
+
if warn:
|
|
63
|
+
warnings.warn(
|
|
64
|
+
"A column-vector y was passed when a 1d array was"
|
|
65
|
+
" expected. Please change the shape of y to "
|
|
66
|
+
"(n_samples, ), for example using ravel().",
|
|
67
|
+
DataConversionWarning,
|
|
68
|
+
stacklevel=2,
|
|
69
|
+
)
|
|
70
|
+
return np.ravel(y)
|
|
71
|
+
|
|
72
|
+
raise ValueError(
|
|
73
|
+
"y should be a 1d array, " "got an array of shape {} instead.".format(shape)
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _compute_class_weight(class_weight, classes, y):
|
|
78
|
+
if set(y) - set(classes):
|
|
79
|
+
raise ValueError("classes should include all valid labels that can " "be in y")
|
|
80
|
+
if class_weight is None or len(class_weight) == 0:
|
|
81
|
+
weight = np.ones(classes.shape[0], dtype=np.float64, order="C")
|
|
82
|
+
elif class_weight == "balanced":
|
|
83
|
+
y_ = _column_or_1d(y)
|
|
84
|
+
classes, _ = np.unique(y_, return_inverse=True)
|
|
85
|
+
|
|
86
|
+
le = LabelEncoder()
|
|
87
|
+
y_ind = le.fit_transform(y_)
|
|
88
|
+
if not all(np.in1d(classes, le.classes_)):
|
|
89
|
+
raise ValueError("classes should have valid labels that are in y")
|
|
90
|
+
|
|
91
|
+
y_bin = np.bincount(y_ind).astype(np.float64)
|
|
92
|
+
weight = len(y_) / (len(le.classes_) * y_bin)
|
|
93
|
+
else:
|
|
94
|
+
# user-defined dictionary
|
|
95
|
+
weight = np.ones(classes.shape[0], dtype=np.float64, order="C")
|
|
96
|
+
if not isinstance(class_weight, dict):
|
|
97
|
+
raise ValueError(
|
|
98
|
+
"class_weight must be dict, 'balanced', or None,"
|
|
99
|
+
" got: %r" % class_weight
|
|
100
|
+
)
|
|
101
|
+
for c in class_weight:
|
|
102
|
+
i = np.searchsorted(classes, c)
|
|
103
|
+
if i >= len(classes) or classes[i] != c:
|
|
104
|
+
raise ValueError("Class label {} not present.".format(c))
|
|
105
|
+
weight[i] = class_weight[c]
|
|
106
|
+
|
|
107
|
+
return weight
|
|
108
|
+
|
|
109
|
+
|
|
110
|
+
def _validate_targets(y, class_weight, dtype):
|
|
111
|
+
y_ = _column_or_1d(y, warn=True)
|
|
112
|
+
_check_classification_targets(y)
|
|
113
|
+
classes, y = np.unique(y_, return_inverse=True)
|
|
114
|
+
class_weight_res = _compute_class_weight(class_weight, classes=classes, y=y_)
|
|
115
|
+
|
|
116
|
+
if len(classes) < 2:
|
|
117
|
+
raise ValueError(
|
|
118
|
+
"The number of classes has to be greater than one; got %d"
|
|
119
|
+
" class" % len(classes)
|
|
120
|
+
)
|
|
121
|
+
|
|
122
|
+
return np.asarray(y, dtype=dtype, order="C"), class_weight_res, classes
|
|
123
|
+
|
|
124
|
+
|
|
125
|
+
def _check_array(
|
|
126
|
+
array,
|
|
127
|
+
dtype="numeric",
|
|
128
|
+
accept_sparse=False,
|
|
129
|
+
order=None,
|
|
130
|
+
copy=False,
|
|
131
|
+
force_all_finite=True,
|
|
132
|
+
ensure_2d=True,
|
|
133
|
+
accept_large_sparse=True,
|
|
134
|
+
):
|
|
135
|
+
if force_all_finite:
|
|
136
|
+
if sp.issparse(array):
|
|
137
|
+
if hasattr(array, "data"):
|
|
138
|
+
_assert_all_finite(array.data)
|
|
139
|
+
force_all_finite = False
|
|
140
|
+
else:
|
|
141
|
+
_assert_all_finite(array)
|
|
142
|
+
force_all_finite = False
|
|
143
|
+
array = check_array(
|
|
144
|
+
array=array,
|
|
145
|
+
dtype=dtype,
|
|
146
|
+
accept_sparse=accept_sparse,
|
|
147
|
+
order=order,
|
|
148
|
+
copy=copy,
|
|
149
|
+
force_all_finite=force_all_finite,
|
|
150
|
+
ensure_2d=ensure_2d,
|
|
151
|
+
accept_large_sparse=accept_large_sparse,
|
|
152
|
+
)
|
|
153
|
+
|
|
154
|
+
if sp.issparse(array):
|
|
155
|
+
return array
|
|
156
|
+
|
|
157
|
+
# TODO: Convert this kind of arrays to a table like in daal4py
|
|
158
|
+
if not array.flags.aligned and not array.flags.writeable:
|
|
159
|
+
array = np.array(array.tolist())
|
|
160
|
+
|
|
161
|
+
# TODO: If data is not contiguous copy to contiguous
|
|
162
|
+
# Need implemeted numpy table in oneDAL
|
|
163
|
+
if not array.flags.c_contiguous and not array.flags.f_contiguous:
|
|
164
|
+
array = np.ascontiguousarray(array, array.dtype)
|
|
165
|
+
return array
|
|
166
|
+
|
|
167
|
+
|
|
168
|
+
def _check_X_y(
|
|
169
|
+
X,
|
|
170
|
+
y,
|
|
171
|
+
dtype="numeric",
|
|
172
|
+
accept_sparse=False,
|
|
173
|
+
order=None,
|
|
174
|
+
copy=False,
|
|
175
|
+
force_all_finite=True,
|
|
176
|
+
ensure_2d=True,
|
|
177
|
+
accept_large_sparse=True,
|
|
178
|
+
y_numeric=False,
|
|
179
|
+
accept_2d_y=False,
|
|
180
|
+
):
|
|
181
|
+
if y is None:
|
|
182
|
+
raise ValueError("y cannot be None")
|
|
183
|
+
|
|
184
|
+
X = _check_array(
|
|
185
|
+
X,
|
|
186
|
+
accept_sparse=accept_sparse,
|
|
187
|
+
dtype=dtype,
|
|
188
|
+
order=order,
|
|
189
|
+
copy=copy,
|
|
190
|
+
force_all_finite=force_all_finite,
|
|
191
|
+
ensure_2d=ensure_2d,
|
|
192
|
+
accept_large_sparse=accept_large_sparse,
|
|
193
|
+
)
|
|
194
|
+
|
|
195
|
+
if not accept_2d_y:
|
|
196
|
+
y = _column_or_1d(y, warn=True)
|
|
197
|
+
else:
|
|
198
|
+
y = np.ascontiguousarray(y)
|
|
199
|
+
|
|
200
|
+
if y_numeric and y.dtype.kind == "O":
|
|
201
|
+
y = y.astype(np.float64)
|
|
202
|
+
if force_all_finite:
|
|
203
|
+
_assert_all_finite(y)
|
|
204
|
+
|
|
205
|
+
lengths = [X.shape[0], y.shape[0]]
|
|
206
|
+
uniques = np.unique(lengths)
|
|
207
|
+
if len(uniques) > 1:
|
|
208
|
+
raise ValueError(
|
|
209
|
+
"Found input variables with inconsistent numbers of"
|
|
210
|
+
" samples: %r" % [int(length) for length in lengths]
|
|
211
|
+
)
|
|
212
|
+
|
|
213
|
+
return X, y
|
|
214
|
+
|
|
215
|
+
|
|
216
|
+
def _check_classification_targets(y):
|
|
217
|
+
y_type = _type_of_target(y)
|
|
218
|
+
if y_type not in [
|
|
219
|
+
"binary",
|
|
220
|
+
"multiclass",
|
|
221
|
+
"multiclass-multioutput",
|
|
222
|
+
"multilabel-indicator",
|
|
223
|
+
"multilabel-sequences",
|
|
224
|
+
]:
|
|
225
|
+
raise ValueError("Unknown label type: %r" % y_type)
|
|
226
|
+
|
|
227
|
+
|
|
228
|
+
def _type_of_target(y):
|
|
229
|
+
is_sequence, is_array = isinstance(y, Sequence), hasattr(y, "__array__")
|
|
230
|
+
is_not_string, is_sparse = not isinstance(y, str), sp.issparse(y)
|
|
231
|
+
valid = (is_sequence or is_array or is_sparse) and is_not_string
|
|
232
|
+
|
|
233
|
+
if not valid:
|
|
234
|
+
raise ValueError(
|
|
235
|
+
"Expected array-like (array or non-string sequence), " "got %r" % y
|
|
236
|
+
)
|
|
237
|
+
|
|
238
|
+
sparse_pandas = y.__class__.__name__ in ["SparseSeries", "SparseArray"]
|
|
239
|
+
if sparse_pandas:
|
|
240
|
+
raise ValueError("y cannot be class 'SparseSeries' or 'SparseArray'")
|
|
241
|
+
|
|
242
|
+
if _is_multilabel(y):
|
|
243
|
+
return "multilabel-indicator"
|
|
244
|
+
|
|
245
|
+
# DeprecationWarning will be replaced by ValueError, see NEP 34
|
|
246
|
+
# https://numpy.org/neps/nep-0034-infer-dtype-is-object.html
|
|
247
|
+
with warnings.catch_warnings():
|
|
248
|
+
warnings.simplefilter("error", VisibleDeprecationWarning)
|
|
249
|
+
try:
|
|
250
|
+
y = np.asarray(y)
|
|
251
|
+
except VisibleDeprecationWarning:
|
|
252
|
+
# dtype=object should be provided explicitly for ragged arrays,
|
|
253
|
+
# see NEP 34
|
|
254
|
+
y = np.asarray(y, dtype=object)
|
|
255
|
+
|
|
256
|
+
# The old sequence of sequences format
|
|
257
|
+
try:
|
|
258
|
+
if (
|
|
259
|
+
not hasattr(y[0], "__array__")
|
|
260
|
+
and isinstance(y[0], Sequence)
|
|
261
|
+
and not isinstance(y[0], str)
|
|
262
|
+
):
|
|
263
|
+
raise ValueError(
|
|
264
|
+
"You appear to be using a legacy multi-label data"
|
|
265
|
+
" representation. Sequence of sequences are no"
|
|
266
|
+
" longer supported; use a binary array or sparse"
|
|
267
|
+
" matrix instead - the MultiLabelBinarizer"
|
|
268
|
+
" transformer can convert to this format."
|
|
269
|
+
)
|
|
270
|
+
except IndexError:
|
|
271
|
+
pass
|
|
272
|
+
|
|
273
|
+
# Invalid inputs
|
|
274
|
+
if y.ndim > 2 or (y.dtype == object and len(y) and not isinstance(y.flat[0], str)):
|
|
275
|
+
return "unknown" # [[[1, 2]]] or [obj_1] and not ["label_1"]
|
|
276
|
+
|
|
277
|
+
if y.ndim == 2 and y.shape[1] == 0:
|
|
278
|
+
return "unknown" # [[]]
|
|
279
|
+
|
|
280
|
+
if y.ndim == 2 and y.shape[1] > 1:
|
|
281
|
+
suffix = "-multioutput" # [[1, 2], [1, 2]]
|
|
282
|
+
else:
|
|
283
|
+
suffix = "" # [1, 2, 3] or [[1], [2], [3]]
|
|
284
|
+
|
|
285
|
+
# check float and contains non-integer float values
|
|
286
|
+
if y.dtype.kind == "f" and np.any(y != y.astype(int)):
|
|
287
|
+
# [.1, .2, 3] or [[.1, .2, 3]] or [[1., .2]] and not [1., 2., 3.]
|
|
288
|
+
_assert_all_finite(y)
|
|
289
|
+
return "continuous" + suffix
|
|
290
|
+
|
|
291
|
+
if (len(np.unique(y)) > 2) or (y.ndim >= 2 and len(y[0]) > 1):
|
|
292
|
+
return "multiclass" + suffix # [1, 2, 3] or [[1., 2., 3]] or [[1, 2]]
|
|
293
|
+
return "binary" # [1, 2] or [["a"], ["b"]]
|
|
294
|
+
|
|
295
|
+
|
|
296
|
+
def _is_integral_float(y):
|
|
297
|
+
return y.dtype.kind == "f" and np.all(y.astype(int) == y)
|
|
298
|
+
|
|
299
|
+
|
|
300
|
+
def _is_multilabel(y):
|
|
301
|
+
if hasattr(y, "__array__") or isinstance(y, Sequence):
|
|
302
|
+
# DeprecationWarning will be replaced by ValueError, see NEP 34
|
|
303
|
+
# https://numpy.org/neps/nep-0034-infer-dtype-is-object.html
|
|
304
|
+
with warnings.catch_warnings():
|
|
305
|
+
warnings.simplefilter("error", VisibleDeprecationWarning)
|
|
306
|
+
try:
|
|
307
|
+
y = np.asarray(y)
|
|
308
|
+
except VisibleDeprecationWarning:
|
|
309
|
+
# dtype=object should be provided explicitly for ragged arrays,
|
|
310
|
+
# see NEP 34
|
|
311
|
+
y = np.array(y, dtype=object)
|
|
312
|
+
|
|
313
|
+
if not (hasattr(y, "shape") and y.ndim == 2 and y.shape[1] > 1):
|
|
314
|
+
return False
|
|
315
|
+
|
|
316
|
+
if sp.issparse(y):
|
|
317
|
+
if isinstance(y, (sp.dok_matrix, sp.lil_matrix)):
|
|
318
|
+
y = y.tocsr()
|
|
319
|
+
return (
|
|
320
|
+
len(y.data) == 0
|
|
321
|
+
or np.unique(y.data).size == 1
|
|
322
|
+
and (y.dtype.kind in "biu" or _is_integral_float(np.unique(y.data)))
|
|
323
|
+
)
|
|
324
|
+
labels = np.unique(y)
|
|
325
|
+
|
|
326
|
+
return len(labels) < 3 and (y.dtype.kind in "biu" or _is_integral_float(labels))
|
|
327
|
+
|
|
328
|
+
|
|
329
|
+
def _check_n_features(self, X, reset):
|
|
330
|
+
try:
|
|
331
|
+
n_features = _num_features(X)
|
|
332
|
+
except TypeError as e:
|
|
333
|
+
if not reset and hasattr(self, "n_features_in_"):
|
|
334
|
+
raise ValueError(
|
|
335
|
+
"X does not contain any features, but "
|
|
336
|
+
f"{self.__class__.__name__} is expecting "
|
|
337
|
+
f"{self.n_features_in_} features"
|
|
338
|
+
) from e
|
|
339
|
+
# If the number of features is not defined and reset=True,
|
|
340
|
+
# then we skip this check
|
|
341
|
+
return
|
|
342
|
+
|
|
343
|
+
if reset:
|
|
344
|
+
self.n_features_in_ = n_features
|
|
345
|
+
return
|
|
346
|
+
|
|
347
|
+
if not hasattr(self, "n_features_in_"):
|
|
348
|
+
# Skip this check if the expected number of expected input features
|
|
349
|
+
# was not recorded by calling fit first. This is typically the case
|
|
350
|
+
# for stateless transformers.
|
|
351
|
+
return
|
|
352
|
+
|
|
353
|
+
if n_features != self.n_features_in_:
|
|
354
|
+
raise ValueError(
|
|
355
|
+
f"X has {n_features} features, but {self.__class__.__name__} "
|
|
356
|
+
f"is expecting {self.n_features_in_} features as input."
|
|
357
|
+
)
|
|
358
|
+
|
|
359
|
+
|
|
360
|
+
def _num_features(X, fallback_1d=False):
|
|
361
|
+
if X is None:
|
|
362
|
+
raise ValueError("Expected array-like (array or non-string sequence), got None")
|
|
363
|
+
type_ = type(X)
|
|
364
|
+
if type_.__module__ == "builtins":
|
|
365
|
+
type_name = type_.__qualname__
|
|
366
|
+
else:
|
|
367
|
+
type_name = f"{type_.__module__}.{type_.__qualname__}"
|
|
368
|
+
message = "Unable to find the number of features from X of type " f"{type_name}"
|
|
369
|
+
if not hasattr(X, "__len__") and not hasattr(X, "shape"):
|
|
370
|
+
if not hasattr(X, "__array__"):
|
|
371
|
+
raise ValueError(message)
|
|
372
|
+
# Only convert X to a numpy array if there is no cheaper, heuristic
|
|
373
|
+
# option.
|
|
374
|
+
X = np.asarray(X)
|
|
375
|
+
|
|
376
|
+
if hasattr(X, "shape"):
|
|
377
|
+
ndim_thr = 1 if fallback_1d else 2
|
|
378
|
+
if not hasattr(X.shape, "__len__") or len(X.shape) < ndim_thr:
|
|
379
|
+
message += f" with shape {X.shape}"
|
|
380
|
+
raise ValueError(message)
|
|
381
|
+
if len(X.shape) <= 1:
|
|
382
|
+
return 1
|
|
383
|
+
else:
|
|
384
|
+
return X.shape[-1]
|
|
385
|
+
|
|
386
|
+
try:
|
|
387
|
+
first_sample = X[0]
|
|
388
|
+
except IndexError:
|
|
389
|
+
raise ValueError("Passed empty data.")
|
|
390
|
+
|
|
391
|
+
# Do not consider an array-like of strings or dicts to be a 2D array
|
|
392
|
+
if isinstance(first_sample, (str, bytes, dict)):
|
|
393
|
+
message += f" where the samples are of type " f"{type(first_sample).__qualname__}"
|
|
394
|
+
raise ValueError(message)
|
|
395
|
+
|
|
396
|
+
try:
|
|
397
|
+
# If X is a list of lists, for instance, we assume that all nested
|
|
398
|
+
# lists have the same length without checking or converting to
|
|
399
|
+
# a numpy array to keep this function call as cheap as possible.
|
|
400
|
+
if (not fallback_1d) or hasattr(first_sample, "__len__"):
|
|
401
|
+
return len(first_sample)
|
|
402
|
+
else:
|
|
403
|
+
return 1
|
|
404
|
+
except Exception as err:
|
|
405
|
+
raise ValueError(message) from err
|
|
406
|
+
|
|
407
|
+
|
|
408
|
+
def _num_samples(x):
|
|
409
|
+
message = "Expected sequence or array-like, got %s" % type(x)
|
|
410
|
+
if hasattr(x, "fit") and callable(x.fit):
|
|
411
|
+
# Don't get num_samples from an ensembles length!
|
|
412
|
+
raise TypeError(message)
|
|
413
|
+
|
|
414
|
+
if not hasattr(x, "__len__") and not hasattr(x, "shape"):
|
|
415
|
+
if hasattr(x, "__array__"):
|
|
416
|
+
x = np.asarray(x)
|
|
417
|
+
else:
|
|
418
|
+
raise TypeError(message)
|
|
419
|
+
|
|
420
|
+
if hasattr(x, "shape") and x.shape is not None:
|
|
421
|
+
if len(x.shape) == 0:
|
|
422
|
+
raise TypeError(
|
|
423
|
+
"Singleton array %r cannot be considered a valid collection." % x
|
|
424
|
+
)
|
|
425
|
+
# Check that shape is returning an integer or default to len
|
|
426
|
+
# Dask dataframes may not return numeric shape[0] value
|
|
427
|
+
if hasattr(x, "shape") and isinstance(x.shape[0], Integral):
|
|
428
|
+
return x.shape[0]
|
|
429
|
+
|
|
430
|
+
try:
|
|
431
|
+
return len(x)
|
|
432
|
+
except TypeError as type_error:
|
|
433
|
+
raise TypeError(message) from type_error
|
|
434
|
+
|
|
435
|
+
|
|
436
|
+
def _is_csr(x):
|
|
437
|
+
"""Return True if x is scipy.sparse.csr_matrix or scipy.sparse.csr_array"""
|
|
438
|
+
return isinstance(x, sp.csr_matrix) or (
|
|
439
|
+
hasattr(sp, "csr_array") and isinstance(x, sp.csr_array)
|
|
440
|
+
)
|
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or
|
|
95
|
+
Derivative Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work,
|
|
103
|
+
excluding those notices that do not pertain to any part of
|
|
104
|
+
the Derivative Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one
|
|
111
|
+
of the following places: within a NOTICE text file distributed
|
|
112
|
+
as part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and
|
|
117
|
+
do not modify the License. You may add Your own attribution
|
|
118
|
+
notices within Derivative Works that You distribute, alongside
|
|
119
|
+
or as an addendum to the NOTICE text from the Work, provided
|
|
120
|
+
that such additional attribution notices cannot be construed
|
|
121
|
+
as modifying the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
Copyright 2017, The TensorFlow Authors.
|
|
189
|
+
|
|
190
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
191
|
+
you may not use this file except in compliance with the License.
|
|
192
|
+
You may obtain a copy of the License at
|
|
193
|
+
|
|
194
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
195
|
+
|
|
196
|
+
Unless required by applicable law or agreed to in writing, software
|
|
197
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
198
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
199
|
+
See the License for the specific language governing permissions and
|
|
200
|
+
limitations under the License.
|
|
201
|
+
|
|
202
|
+
* Other names and brands may be claimed as the property of others.
|