8000 MAINT Complete 0.20 deprecations (#9570) · wdevazelhes/scikit-learn@eec7649 · GitHub
[go: up one dir, main page]

Skip to content

Commit eec7649

Browse files
amuellerjnothman
authored andcommitted
MAINT Complete 0.20 deprecations (scikit-learn#9570)
1 parent 9e5dc00 commit eec7649

Some content is hidden

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

48 files changed

+67
-10265
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ benchmarks/bench_covertype_data/
5454
*.prefs
5555
.pydevproject
5656
.idea
57+
.vscode
5758

5859
*.c
5960
*.cpp

benchmarks/bench_plot_incremental_pca.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
from collections import defaultdict
1414
import matplotlib.pyplot as plt
1515
from sklearn.datasets import fetch_lfw_people
16-
from sklearn.decomposition import IncrementalPCA, RandomizedPCA, PCA
16+
from sklearn.decomposition import IncrementalPCA, PCA
1717

1818

1919
def plot_results(X, y, label):
@@ -37,7 +37,6 @@ def plot_feature_times(all_times, batch_size, all_components, data):
3737
plot_results(all_components, all_times['pca'], label="PCA")
3838
plot_results(all_components, all_times['ipca'],
3939
label="IncrementalPCA, bsize=%i" % batch_size)
40-
plot_results(all_components, all_times['rpca'], label="RandomizedPCA")
4140
plt.legend(loc="upper left")
4241
plt.suptitle("Algorithm runtime vs. n_components\n \
4342
LFW, size %i x %i" % data.shape)
@@ -50,7 +49,6 @@ def plot_feature_errors(all_errors, batch_size, all_components, data):
5049
plot_results(all_components, all_errors['pca'], label="PCA")
5150
plot_results(all_components, all_errors['ipca'],
5251
label="IncrementalPCA, bsize=%i" % batch_size)
53-
plot_results(all_components, all_errors['rpca'], label="RandomizedPCA")
5452
plt.legend(loc="lower left")
5553
plt.suptitle("Algorithm error vs. n_components\n"
5654
"LFW, size %i x %i" % data.shape)
@@ -61,7 +59,6 @@ def plot_feature_errors(all_errors, batch_size, all_components, data):
6159
def plot_batch_times(all_times, n_features, all_batch_sizes, data):
6260
plt.figure()
6361
plot_results(all_batch_sizes, all_times['pca'], label="PCA")
64-
plot_results(all_batch_sizes, all_times['rpca'], label="RandomizedPCA")
6562
plot_results(all_batch_sizes, all_times['ipca'], label="IncrementalPCA")
6663
plt.legend(loc="lower left")
6764
plt.suptitle("Algorithm runtime vs. batch_size for n_components %i\n \
@@ -92,11 +89,9 @@ def fixed_batch_size_comparison(data):
9289
all_errors = defaultdict(list)
9390
for n_components in all_features:
9491
pca = PCA(n_components=n_components)
95-
rpca = RandomizedPCA(n_components=n_components, random_state=1999)
9692
ipca = IncrementalPCA(n_components=n_components, batch_size=batch_size)
9793
results_dict = {k: benchmark(est, data) for k, est in [('pca', pca),
98-
('ipca', ipca),
99-
('rpca', rpca)]}
94+
('ipca', ipca)]}
10095

10196
for k in sorted(results_dict.keys()):
10297
all_times[k].append(results_dict[k]['time'])
@@ -116,7 +111,8 @@ def variable_batch_size_comparison(data):
116111
all_times = defaultdict(list)
117112
all_errors = defaultdict(list)
118113
pca = PCA(n_components=n_components)
119-
rpca = RandomizedPCA(n_components=n_components, random_state=1999)
114+
rpca = PCA(n_components=n_components, svd_solver='randomized',
115+
random_state=1999)
120116
results_dict = {k: benchmark(est, data) for k, est in [('pca', pca),
121117
('rpca', rpca)]}
122118

@@ -138,8 +134,6 @@ def variable_batch_size_comparison(data):
138134
all_errors['ipca'].append(results_dict['ipca']['error'])
139135

140136
plot_batch_times(all_times, n_components, batch_sizes, data)
141-
# RandomizedPCA error is always worse (approx 100x) than other PCA
142-
# tests
143137
plot_batch_errors(all_errors, n_components, batch_sizes, data)
144138

145139
faces = fetch_lfw_people(resize=.2, min_faces_per_person=5)

doc/modules/classes.rst

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1511,46 +1511,3 @@ To be removed in 0.21
15111511

15121512
datasets.load_mlcomp
15131513
linear_model.lasso_stability_path
1514-
1515-
1516-
To be removed in 0.20
1517-
---------------------
1518-
1519-
.. autosummary::
1520-
:toctree: generated/
1521-
:template: deprecated_class.rst
1522-
1523-
cross_validation.KFold
1524-
cross_validation.LabelKFold
1525-
cross_validation.LeaveOneLabelOut
1526-
cross_validation.LeaveOneOut
1527-
cross_validation.LeavePOut
1528-
cross_validation.LeavePLabelOut
1529-
cross_validation.LabelShuffleSplit
1530-
cross_validation.ShuffleSplit
1531-
cross_validation.StratifiedKFold
1532-
cross_validation.StratifiedShuffleSplit
1533-
cross_validation.PredefinedSplit
1534-
decomposition.RandomizedPCA
1535-
gaussian_process.GaussianProcess
1536-
grid_search.ParameterGrid
1537-
grid_search.ParameterSampler
1538-
grid_search.GridSearchCV
1539-
grid_search.RandomizedSearchCV
1540-
mixture.DPGMM
1541-
mixture.GMM
1542-
mixture.VBGMM
1543-
1544-
1545-
.. autosummary::
1546-
:toctree: generated/
1547-
:template: deprecated_function.rst
1548-
1549-
cross_validation.check_cv
1550-
cross_validation.cross_val_predict
1551-
cross_validation.cross_val_score
1552-
cross_validation.permutation_test_score
1553-
cross_validation.train_test_split
1554-
grid_search.fit_grid_point
1555-
learning_curve.learning_curve
1556-
learning_curve.validation_curve

doc/modules/preprocessing.rst

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -235,9 +235,8 @@ data.
235235
independently, since a downstream model can further make some assumption
236236
on the linear independence of the features.
237237

238-
To address this issue you can use :class:`sklearn.decomposition.PCA`
239-
or :class:`sklearn.decomposition.RandomizedPCA` with ``whiten=True``
240-
to further remove the linear correlation across features.
238+
To address this issue you can use :class:`sklearn.decomposition.PCA` with
239+
``whiten=True`` to further remove the linear correlation across features.
241240

242241
.. topic:: Scaling a 1D array
243242

doc/tutorial/machine_learning_map/index.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ Click on any estimator in the chart below to see its documentation.
100100
<area href="../../modules/svm.html#classification" title="SVC Documentation" shape="poly" coords="210,157, 210,157, 210,194, 210,194, 210,194, 333,194, 333,194, 333,194, 333,157, 333,157, 333,157, 210,157, 210,157" data-maphilight='{"strokeColor":"0000ff","strokeWidth":5,"fillColor":"66FF66","fillOpacity":0.4}'></area>
101101
<area href="../../modules/svm.html#regression" title="SVR Documentation" shape="poly" coords="1696,692, 1696,692, 1696,732, 1696,732, 1696,732, 1890,732, 1890,732, 1890,732, 1890,692, 1890,692, 1890,692, 1696,692, 1696,692" data-maphilight='{"strokeColor":"0000ff","strokeWidth":5,"fillColor":"66FF66","fillOpacity":0.4}'></area>
102102
<area href="../../modules/svm.html#regression" title="SVR Documentation" shape="poly" coords="1831,458, 1831,458, 1831,496, 1831,496, 1831,496, 2052,496, 2052,496, 2052,496, 2052,458, 2052,458, 2052,458, 1831,458, 1831,458" data-maphilight='{"strokeColor":"0000ff","strokeWidth":5,"fillColor":"66FF66","fillOpacity":0.4}'></area>
103-
<area href="../../modules/mixture.html#vbgmm-classifier-variational-gaussian-mixtures" title=" VBGMM Documentation" shape="poly" coords="562,994, 562,994, 562,1026, 562,1026, 562,1026, 682,1026, 682,1026, 682,1026, 682,994, 682,994, 682,994, 562,994, 562,994" data-maphilight='{"strokeColor":"0000ff","strokeWidth":5,"fillColor":"66FF66","fillOpacity":0.4}'></area>
103+
<area href="../../modules/mixture.html#bgmm" title=" Bayesian GMM Documentation" shape="poly" coords="562,994, 562,994, 562,1026, 562,1026, 562,1026, 682,1026, 682,1026, 682,1026, 682,994, 682,994, 682,994, 562,994, 562,994" data-maphilight='{"strokeColor":"0000ff","strokeWidth":5,"fillColor":"66FF66","fillOpacity":0.4}'></area>
104104
</map>
105105
</img>
106106
</p>

examples/model_selection/plot_nested_cross_validation_iris.py

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

7676
# Choose cross-validation techniques for the inner and outer loops,
7777
# independently of the dataset.
78-
# E.g "LabelKFold", "LeaveOneOut", "LeaveOneLabelOut", etc.
78+
# E.g "GroupKFold", "LeaveOneOut", "LeaveOneGroupOut", etc.
7979
inner_cv = KFold(n_splits=4, shuffle=True, random_state=i)
8080
outer_cv = KFold(n_splits=4, shuffle=True, random_state=i)
8181

sklearn/__init__.py

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,11 +65,10 @@
6565
__check_build # avoid flakes unused variable error
6666

6767
__all__ = ['calibration', 'cluster', 'covariance', 'cross_decomposition',
68-
'cross_validation', 'datasets', 'decomposition', 'dummy',
69-
'ensemble', 'exceptions', 'externals', 'feature_extraction',
70-
'feature_selection', 'gaussian_process', 'grid_search',
71-
'isotonic', 'kernel_approximation', 'kernel_ridge',
72-
'learning_curve', 'linear_model', 'manifold', 'metrics',
68+
'datasets', 'decomposition', 'dummy', 'ensemble', 'exceptions',
69+
'externals', 'feature_extraction', 'feature_selection',
70+
'gaussian_process', 'isotonic', 'kernel_approximation',
71+
'kernel_ridge', 'linear_model', 'manifold', 'metrics',
7372
'mixture', 'model_selection', 'multiclass', 'multioutput',
7473
'naive_bayes', 'neighbors', 'neural_network', 'pipeline',
7574
'preprocessing', 'random_projection', 'semi_supervised',

sklearn/base.py

Lines changed: 2 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -67,57 +67,10 @@ def clone(estimator, safe=True):
6767
for name in new_object_params:
6868
param1 = new_object_params[name]
6969
param2 = params_set[name]
70-
if param1 is param2:
71-
# this should always happen
72-
continue
73-
if isinstance(param1, np.ndarray):
74-
# For most ndarrays, we do not test for complete equality
75-
if not isinstance(param2, type(param1)):
76-
equality_test = False
77-
elif (param1.ndim > 0
78-
and param1.shape[0] > 0
79-
and isinstance(param2, np.ndarray)
80-
and param2.ndim > 0
81-
and param2.shape[0] > 0):
82-
equality_test = (
83-
param1.shape == param2.shape
84-
and param1.dtype == param2.dtype
85-
and (_first_and_last_element(param1) ==
86-
_first_and_last_element(param2))
87-
)
88-
else:
89-
equality_test = np.all(param1 == param2)
90-
elif sparse.issparse(param1):
91-
# For sparse matrices equality doesn't work
92-
if not sparse.issparse(param2):
93-
equality_test = False
94-
elif param1.size == 0 or param2.size == 0:
95-
equality_test = (
96-
param1.__class__ == param2.__class__
97-
and param1.size == 0
98-
and param2.size == 0
99-
)
100-
else:
101-
equality_test = (
102-
param1.__class__ == param2.__class__
103-
and (_first_and_last_element(param1) ==
104-
_first_and_last_element(param2))
105-
and param1.nnz == param2.nnz
106-
and param1.shape == param2.shape
107-
)
108-
else:
109-
# fall back on standard equality
110-
equality_test = param1 == param2
111-
if equality_test:
112-
warnings.warn("Estimator %s modifies parameters in __init__."
113-
" This behavior is deprecated as of 0.18 and "
114-
"support for this behavior will be removed in 0.20."
115-
% type(estimator).__name__, DeprecationWarning)
116-
else:
70+
if param1 is not param2:
11771
raise RuntimeError('Cannot clone object %s, as the constructor '
118-
'does not seem to set parameter %s' %
72+
'either does not set or modifies parameter %s' %
11973
(estimator, name))
120-
12174
return new_object
12275

12376

sklearn/cluster/tests/test_hierarchical.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def test_deprecation_of_n_components_in_linkage_tree():
5151
assert_equal(n_leaves, n_leaves_t)
5252
assert_equal(parent, parent_t)
5353

54+
5455
def test_linkage_misc():
5556
# Misc tests on linkage
5657
rng = np.random.RandomState(42)
@@ -511,7 +512,8 @@ def test_connectivity_callable():
511512
connectivity = kneighbors_graph(X, 3, include_self=False)
512513
aglc1 = AgglomerativeClustering(connectivity=connectivity)
513514
aglc2 = AgglomerativeClustering(
514-
connectivity=partial(kneighbors_graph, n_neighbors=3, include_self=False))
515+
connectivity=partial(kneighbors_graph, n_neighbors=3,
516+
include_self=False))
515517
aglc1.fit(X)
516518
aglc2.fit(X)
517519
assert_array_equal(aglc1.labels_, aglc2.labels_)

0 commit comments

Comments
 (0)
0