8000 Merge branch 'master' into cierroronwarning · scikit-learn/scikit-learn@5ed1c9c · GitHub
[go: up one dir, main page]

Skip to content

Commit 5ed1c9c

Browse files
committed
Merge branch 'master' into cierroronwarning
2 parents a642e32 + 939fa3c commit 5ed1c9c

File tree

87 files changed

+362
-247
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

87 files changed

+362
-247
lines changed

.gitignore

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ _configtest.o.d
7575
# files generated from a template
7676
sklearn/utils/_seq_dataset.pyx
7777
sklearn/utils/_seq_dataset.pxd
78-
sklearn/linear_model/sag_fast.pyx
78+
sklearn/linear_model/_sag_fast.pyx
7979

8080
# deprecated paths
8181
# TODO: Remove in 0.24
@@ -130,6 +130,36 @@ sklearn/svm/libsvm.py
130130
sklearn/svm/libsvm_sparse.py
131131
sklearn/svm/liblinear.py
132132

133+
sklearn/linear_model/base.py
134+
sklearn/linear_model/bayes.py
135+
sklearn/linear_model/cd_fast.py
136+
sklearn/linear_model/coordinate_descent.py
137+
sklearn/linear_model/huber.py
138+
sklearn/linear_model/least_angle.py
139+
sklearn/linear_model/logistic.py
140+
sklearn/linear_model/omp.py
141+
sklearn/linear_model/passive_aggressive.py
142+
sklearn/linear_model/perceptron.py
143+
sklearn/linear_model/ransac.py
144+
sklearn/linear_model/ridge.py
145+
sklearn/linear_model/sag.py
146+
sklearn/linear_model/sag_fast.py
147+
sklearn/linear_model/sgd_fast.py
148+
sklearn/linear_model/stochastic_gradient.py
149+
sklearn/linear_model/theil_sen.py
150+
151+
sklearn/metrics/cluster/bicluster.py
152+
sklearn/metrics/cluster/supervised.py
153+
sklearn/metrics/cluster/unsupervised.py
154+
sklearn/metrics/cluster/expected_mutual_info_fast.py
155+
156+
sklearn/metrics/base.py
157+
sklearn/metrics/classification.py
158+
sklearn/metrics/regression.py
159+
sklearn/metrics/ranking.py
160+
sklearn/metrics/pairwise_fast.py
161+
sklearn/metrics/scorer.py
162+
133163
sklearn/inspection/partial_dependence.py
134164
sklearn/inspection/permutation_importance.py
135165

benchmarks/bench_rcv1_logreg_convergence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from sklearn.linear_model import (LogisticRegression, SGDClassifier)
1313
from sklearn.datasets import fetch_rcv1
14-
from sklearn.linear_model.sag import get_auto_step_size
14+
from sklearn.linear_model._sag import get_auto_step_size
1515

1616
try:
1717
import lightning.classification as lightning_clf

benchmarks/bench_sparsify.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545

4646
from scipy.sparse.csr import csr_matrix
4747
import numpy as np
48-
from sklearn.linear_model.stochastic_gradient import SGDRegressor
48+
from sklearn.linear_model import SGDRegressor
4949
from sklearn.metrics import r2_score
5050

5151
np.random.seed(42)

doc/developers/develop.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ this can be achieved with::
453453
return self.classes_[np.argmax(D, axis=1)]
454454

455455
In linear models, coefficients are stored in an array called ``coef_``, and the
456-
independent term is stored in ``intercept_``. ``sklearn.linear_model.base``
456+
independent term is stored in ``intercept_``. ``sklearn.linear_model._base``
457457
contains a few base classes and mixins that implement comm 10000 on linear model
458458
patterns.
459459

doc/modules/classes.rst

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ Miscellaneous
882882
manifold.locally_linear_embedding
883883
manifold.smacof
884884
manifold.spectral_embedding
885-
manifold.t_sne.trustworthiness
885+
manifold.trustworthiness
886886

887887

888888
.. _metrics_ref:
@@ -1480,20 +1480,6 @@ Estimators
14801480

14811481
svm.l1_min_c
14821482

1483-
Low-level methods
1484-
-----------------
1485-
1486-
.. autosummary::
1487-
:toctree: generated
1488-
:template: function.rst
1489-
1490-
svm.libsvm.cross_validation
1491-
svm.libsvm.decision_function
1492-
svm.libsvm.fit
1493-
svm.libsvm.predict
1494-
svm.libsvm.predict_proba
1495-
1496-
14971483
.. _tree_ref:
14981484

14991485
:mod:`sklearn.tree`: Decision Trees

doc/modules/computing.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -297,7 +297,7 @@ decision function that is applied at prediction time is the same (a dot product)
297297
, so latency should be equivalent.
298298

299299
Here is an example using
300-
:class:`sklearn.linear_model.stochastic_gradient.SGDClassifier` with the
300+
:class:`sklearn.linear_model.SGDClassifier` with the
301301
``elasticnet`` penalty. The regularization strength is globally controlled by
302302
the ``alpha`` parameter. With a sufficiently high ``alpha``,
303303
one can then increase the ``l1_ratio`` parameter of ``elasticnet`` to

doc/modules/cross_validation.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ predefined scorer names::
241241

242242
Or as a dict mapping scorer name to a predefined or custom scoring function::
243243

244-
>>> from sklearn.metrics.scorer import make_scorer
244+
>>> from sklearn.metrics import make_scorer
245245
>>> scoring = {'prec_macro': 'precision_macro',
246246
... 'rec_macro': make_scorer(recall_score, average='macro')}
247247
>>> scores = cross_validate(clf, X, y, scoring=scoring,

doc/templates/index.html

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,11 +182,6 @@ <h4 class="sk-landing-call-header">Community</h4>
182182
<li><strong>Gitter:</strong> <a href="https://gitter.im/scikit-learn/scikit-learn">gitter.im/scikit-learn</a></li>
183183
</ul>
184184

185-
<form target="_top" id="paypal-form" method="post" action="https://www.paypal.com/cgi-bin/webscr">
186-
<input type="hidden" value="_s-xclick" name="cmd">
187-
<input type="hidden" value="74EYUMF3FTSW8" name="hosted_button_id">
188-
</form>
189-
<a class="btn btn-warning btn-big sk-donate-btn mb-1" onclick="document.getElementById('paypal-form').submit(); ">Help us, <strong>donate!</strong></a>
190185
<a class="btn btn-warning btn-big mb-1" href="about.html#citing-scikit-learn"><strong>Cite us!</strong></a>
191186
</div>
192187
<div class="col-md-4">

doc/themes/scikit-learn/static/nature.css_t

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -967,11 +967,6 @@ div.container.index-lower ul li em {
967967
font-weight: bold;
968968
}
969969

970-
#paypal-form {
971-
margin: 30px 0;
972-
padding: 0;
973-
}
974-
975970
div.container.index-lower a.cite-us {
976971
margin-left: 60px;
977972
padding-right: 20px;

doc/whats_new/v0.21.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ random sampling procedures.
228228
- :func:`svm.SVC.decision_function` and
229229
:func:`multiclass.OneVsOneClassifier.decision_function`. |Fix|
230230
- :class:`linear_model.SGDClassifier` and any derived classifiers. |Fix|
231-
- Any model using the :func:`linear_model.sag.sag_solver` function with a `0`
231+
- Any model using the :func:`linear_model._sag.sag_solver` function with a `0`
232232
seed, including :class:`linear_model.LogisticRegression`,
233233
:class:`linear_model.LogisticRegressionCV`, :class:`linear_model.Ridge`,
234234
and :class:`linear_model.RidgeCV` with 'sag' solver. |Fix|

examples/applications/plot_model_complexity_influence.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@
3131
from sklearn.metrics import mean_squared_error
3232
from sklearn.svm import NuSVR
3333
from sklearn.ensemble import GradientBoostingRegressor
34-
from sklearn.linear_model.stochastic_gradient import SGDClassifier
34+
from sklearn.linear_model import SGDClassifier
3535
from sklearn.metrics import hamming_loss
3636

3737
# #############################################################################

examples/linear_model/plot_sgd_penalties.py

< C2EE span aria-hidden="true" class="f6 text-bold fgColor-success">+2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
Contours of where the penalty is equal to 1
77
for the three penalties L1, L2 and elastic-net.
88
9-
All of the above are supported by
10-
:class:`sklearn.linear_model.stochastic_gradient`.
9+
All of the above are supported by :class:`~sklearn.linear_model.SGDClassifier`
10+
and :class:`~sklearn.linear_model.SGDRegressor`.
1111
1212
"""
1313
print(__doc__)

examples/preprocessing/plot_map_data_to_normal.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
Map data to a normal distribution
44
=================================
55
6+
.. currentmodule:: sklearn.preprocessing
7+
68
This example demonstrates the use of the Box-Cox and Yeo-Johnson transforms
7-
through :class:`preprocessing.PowerTransformer` to map data from various
9+
through :class:`~PowerTransformer` to map data from various
810
distributions to a normal distribution.
911
1012
The power transform is useful as a transformation in modeling problems where
@@ -22,7 +24,7 @@
2224
support inputs with negative values.
2325
2426
For comparison, we also add the output from
25-
:class:`preprocessing.QuantileTransformer`. It can force any arbitrary
27+
:class:`~QuantileTransformer`. It can force any arbitrary
2628
distribution into a gaussian, provided that there are enough training samples
2729
(thousands). Because it is a non-parametric method, it is harder to interpret
2830
than the parametric ones (Box-Cox and Yeo-Johnson).

sklearn/_build_utils/deprecated_modules.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,61 @@
8686
'set_verbosity_wrap'),
8787
('_liblinear', 'sklearn.svm.liblinear', 'sklearn.svm', 'train_wrap'),
8888

89+
('_base', 'sklearn.linear_model.base', 'sklearn.linear_model',
90+
'LinearRegression'),
91+
('_cd_fast', 'sklearn.linear_model.cd_fast', 'sklearn.linear_model',
92+
'sparse_enet_coordinate_descent'),
93+
('_bayes', 'sklearn.linear_model.bayes', 'sklearn.linear_model',
94+
'BayesianRidge'),
95+
('_coordinate_descent', 'sklearn.linear_model.coordinate_descent',
96+
'sklearn.linear_model', 'Lasso'),
97+
('_huber', 'sklearn.linear_model.huber', 'sklearn.linear_model',
98+
'HuberRegressor'),
99+
('_least_angle', 'sklearn.linear_model.least_angle',
100+
'sklearn.linear_model', 'LassoLarsCV'),
101+
('_logistic', 'sklearn.linear_model.logistic', 'sklearn.linear_model',
102+
'LogisticRegression'),
103+
('_omp', 'sklearn.linear_model.omp', 'sklearn.linear_model',
104+
'OrthogonalMatchingPursuit'),
105+
('_passive_aggressive', 'sklearn.linear_model.passive_aggressive',
106+
'sklearn.linear_model', 'PassiveAggressiveClassifier'),
107+
('_perceptron', 'sklearn.linear_model.perceptron', 'sklearn.linear_model',
108+
'Perceptron'),
109+
('_ransac', 'sklearn.linear_model.ransac', 'sklearn.linear_model',
110+
'RANSACRegressor'),
111+
('_ridge', 'sklearn.linear_model.ridge', 'sklearn.linear_model',
112+
'Ridge'),
113+
('_sag', 'sklearn.linear_model.sag', 'sklearn.linear_model',
114+
'get_auto_step_size'),
115+
('_sag_fast', 'sklearn.linear_model.sag_fast', 'sklearn.linear_model',
116+
'MultinomialLogLoss64'),
117+
('_sgd_fast', 'sklearn.linear_model.sgd_fast', 'sklearn.linear_model',
118+
'Hinge'),
119+
('_stochastic_gradient', 'sklearn.linear_model.stochastic_gradient',
120+
'sklearn.linear_model', 'SGDClassifier'),
121+
('_theil_sen', 'sklearn.linear_model.theil_sen', 'sklearn.linear_model',
122+
'TheilSenRegressor'),
123+
124+
('_bicluster', 'sklearn.metrics.cluster.bicluster',
125+
'sklearn.metrics.cluster', 'consensus_score'),
126+
('_supervised', 'sklearn.metrics.cluster.supervised',
127+
'sklearn.metrics.cluster', 'entropy'),
128+
('_unsupervised', 'sklearn.metrics.cluster.unsupervised',
129+
'sklearn.metrics.cluster', 'silhouette_score'),
130+
('_expected_mutual_info_fast',
131+
'sklearn.metrics.cluster.expected_mutual_info_fast',
132+
'sklearn.metrics.cluster', 'expected_mutual_information'),
133+
134+
('_base', 'sklearn.metrics.base', 'sklearn.metrics', 'combinations'),
135+
('_classification', 'sklearn.metrics.classification', 'sklearn.metrics',
136+
'accuracy_score'),
137+
('_regression', 'sklearn.metrics.regression', 'sklearn.metrics',
138+
'max_error'),
139+
('_ranking', 'sklearn.metrics.ranking', 'sklearn.metrics', 'roc_curve'),
140+
('_pairwise_fast', 'sklearn.metrics.pairwise_fast', 'sklearn.metrics',
141+
'np'),
142+
('_scorer', 'sklearn.metrics.scorer', 'sklearn.metrics', 'get_scorer'),
143+
89144
('_partial_dependence', 'sklearn.inspection.partial_dependence',
90145
'sklearn.inspection', 'partial_dependence'),
91146
('_permutation_importance', 'sklearn.inspection.permutation_importance',

sklearn/base.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ def score(self, X, y, sample_weight=None):
404404
"""
405405

406406
from .metrics import r2_score
407-
from .metrics.regression import _check_reg_targets
407+
from .metrics._regression import _check_reg_targets
408408
y_pred = self.predict(X)
409409
# XXX: Remove the check in 0.23
410410
y_type, _, _, _ = _check_reg_targets(y, y_pred, None)

sklearn/covariance/_graph_lasso_.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
from ..exceptions import ConvergenceWarning
2121
from ..utils.validation import check_random_state, check_array
22-
from ..linear_model import cd_fast
22+
from ..linear_model import _cd_fast as cd_fast
2323
from ..linear_model import lars_path_gram
2424
from ..model_selection import check_cv, cross_val_score
2525

sklearn/discriminant_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
from scipy.special import expit
1717

1818
from .base import BaseEstimator, TransformerMixin, ClassifierMixin
19-
from .linear_model.base import LinearClassifierMixin
19+
from .linear_model._base import LinearClassifierMixin
2020
from .covariance import ledoit_wolf, empirical_covariance, shrunk_covariance
2121
from .utils.multiclass import unique_labels
2222
from .utils import check_array, check_X_y

sklearn/ensemble/_base.py

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from abc import ABCMeta, abstractmethod
99
import numbers
10+
import warnings
1011

1112
import numpy as np
1213

@@ -223,6 +224,15 @@ def _validate_estimators(self):
223224
# defined by MetaEstimatorMixin
224225
self._validate_names(names)
225226

227+
# FIXME: deprecate the usage of None to drop an estimator from the
228+
# ensemble. Remove in 0.24
229+
if any(est is None for est in estimators):
230+
warnings.warn(
231+
"Using 'None' to drop an estimator from the ensemble is "
232+
"deprecated in 0.22 and support will be dropped in 0.24. "
233+
"Use the string 'drop' instead.", DeprecationWarning
234+
)
235+
226236
has_estimator = any(est not in (None, 'drop') for est in estimators)
227237
if not has_estimator:
228238
raise ValueError(
@@ -236,8 +246,7 @@ def _validate_estimators(self):
236246
for est in estimators:
237247
if est not in (None, 'drop') and not is_estimator_type(est):
238248
raise ValueError(
239-
"The estimator {} should be a {}."
240-
.format(
249+
"The estimator {} should be a {}.".format(
241250
est.__class__.__name__, is_estimator_type.__name__[3:]
242251
)
243252
)

sklearn/ensemble/_voting.py

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,9 +88,13 @@ class VotingClassifier(ClassifierMixin, _BaseVoting):
8888
estimators : list of (string, estimator) tuples
8989
Invoking the ``fit`` method on the ``VotingClassifier`` will fit clones
9090
of those original estimators that will be stored in the class attribute
91-
``self.estimators_``. An estimator can be set to ``None`` or ``'drop'``
91+
``self.estimators_``. An estimator can be set to ``'drop'``
9292
using ``set_params``.
9393
94+
.. deprecated:: 0.22
95+
Using ``None`` to drop an estimator is deprecated in 0.22 and
96+
support will be dropped in 0.24. Use the string ``'drop'`` instead.
97+
9498
voting : str, {'hard', 'soft'} (default='hard')
9599
If 'hard', uses predicted class labels for majority rule voting.
96100
Else if 'soft', predicts the class label based on the argmax of
@@ -119,7 +123,7 @@ class VotingClassifier(ClassifierMixin, _BaseVoting):
119123
----------
120124
estimators_ : list of classifiers
121125
The collection of fitted sub-estimators as defined in ``estimators``
122-
that are not `None`.
126+
that are not 'drop'.
123127
124128
named_estimators_ : Bunch object, a dictionary with attribute access
125129
Attribute to access any fitted sub-estimators by name.
@@ -322,8 +326,12 @@ class VotingRegressor(RegressorMixin, _BaseVoting):
322326
estimators : list of (string, estimator) tuples
323327
Invoking the ``fit`` method on the ``VotingRegressor`` will fit clones
324328
of those original estimators that will be stored in the class attribute
325-
``self.estimators_``. An estimator can be set to ``None`` or ``'drop'``
326-
using ``set_params``.
329+
``self.estimators_``. An estimator can be set to ``'drop'`` using
330+
``set_params``.
331+
332+
.. deprecated:: 0.22
333+
Using ``None`` to drop an estimator is deprecated in 0.22 and
334+
support will be dropped in 0.24. Use the string ``'drop'`` instead.
327335
328336
weights : array-like, shape (n_regressors,), optional (default=`None`)
329337
Sequence of weights (`float` or `int`) to weight the occurrences of
@@ -339,11 +347,13 @@ class VotingRegressor(RegressorMixin, _BaseVoting):
339347
----------
340348
estimators_ : list of regressors
341349
The collection of fitted sub-estimators as defined in ``estimators``
342-
that are not `None`.
350+
that are not 'drop'.
343351
344352
named_estimators_ : Bunch object, a dictionary with attribute access
345353
Attribute to access any fitted sub-estimators by name.
346354
355+
.. versionadded:: 0.20
356+
347357
Examples
348358
--------
349359
>>> import numpy as np

0 commit comments

Comments
 (0)
0