Skip to content

Commit 0b8d362

Browse files
amuellerrth
authored andcommitted
[MRG] Examples deprecations (scikit-learn#11561)
1 parent db3b84e commit 0b8d362

18 files changed

+34
-37
lines changed

examples/applications/plot_prediction_latency.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def generate_dataset(n_train, n_test, n_features, noise=0.1, verbose=False):
102102

103103
random_seed = 13
104104
X_train, X_test, y_train, y_test = train_test_split(
105-
X, y, train_size=n_train, random_state=random_seed)
105+
X, y, train_size=n_train, test_size=n_test, random_state=random_seed)
106106
X_train, y_train = shuffle(X_train, y_train, random_state=random_seed)
107107

108108
X_scaler = StandardScaler()

examples/applications/plot_species_distribution_modeling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ def plot_species_distribution(species=("bradypus_variegatus_0",
154154
else:
155155
print(" - plot coastlines from coverage")
156156
plt.contour(X, Y, land_reference,
157-
levels=[-9999], colors="k",
157+
levels=[-9998], colors="k",
158158
linestyles="solid")
159159
plt.xticks([])
160160
plt.yticks([])

examples/classification/plot_classification_probability.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ class dataset, and we classify it with a Support Vector classifier, L1
7676
plt.yticks(())
7777
idx = (y_pred == k)
7878
if idx.any():
79-
plt.scatter(X[idx, 0], X[idx, 1], marker='o', c='k')
79+
plt.scatter(X[idx, 0], X[idx, 1], marker='o', c='w', edgecolor='k')
8080

8181
ax = plt.axes([0.15, 0.04, 0.7, 0.05])
8282
plt.title("Probability")

examples/classification/plot_lda_qda.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,8 +130,8 @@ def plot_lda_cov(lda, splot):
130130

131131

132132
def plot_qda_cov(qda, splot):
133-
plot_ellipse(splot, qda.means_[0], qda.covariances_[0], 'red')
134-
plot_ellipse(splot, qda.means_[1], qda.covariances_[1], 'blue')
133+
plot_ellipse(splot, qda.means_[0], qda.covariance_[0], 'red')
134+
plot_ellipse(splot, qda.means_[1], qda.covariance_[1], 'blue')
135135

136136
for i, (X, y) in enumerate([dataset_fixed_cov(), dataset_cov()]):
137137
# Linear Discriminant Analysis

examples/cluster/plot_kmeans_silhouette_analysis.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,4 +139,4 @@
139139
"with n_clusters = %d" % n_clusters),
140140
fontsize=14, fontweight='bold')
141141

142-
plt.show()
142+
plt.show()

examples/ensemble/plot_feature_transformation.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@
6262

6363
# Supervised transformation based on random forests
6464
rf = RandomForestClassifier(max_depth=3, n_estimators=n_estimator)
65-
rf_enc = OneHotEncoder()
65+
rf_enc = OneHotEncoder(categories='auto')
6666
rf_lm = LogisticRegression()
6767
rf.fit(X_train, y_train)
6868
rf_enc.fit(rf.apply(X_train))
@@ -72,7 +72,7 @@
7272
fpr_rf_lm, tpr_rf_lm, _ = roc_curve(y_test, y_pred_rf_lm)
7373

7474
grd = GradientBoostingClassifier(n_estimators=n_estimator)
75-
grd_enc = OneHotEncoder()
75+
grd_enc = OneHotEncoder(categories='auto')
7676
grd_lm = LogisticRegression()
7777
grd.fit(X_train, y_train)
7878
grd_enc.fit(grd.apply(X_train)[:, :, 0])

examples/ensemble/plot_isolation_forest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
X_outliers = rng.uniform(low=-4, high=4, size=(20, 2))
4141

4242
# fit the model
43-
clf = IsolationForest(max_samples=100, random_state=rng)
43+
clf = IsolationForest(max_samples=100, random_state=rng, contamination='auto')
4444
clf.fit(X_train)
4545
y_pred_train = clf.predict(X_train)
4646
y_pred_test = clf.predict(X_test)

examples/ensemble/plot_random_forest_regression_multioutput.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,8 @@
3939
y = np.array([np.pi * np.sin(X).ravel(), np.pi * np.cos(X).ravel()]).T
4040
y += (0.5 - rng.rand(*y.shape))
4141

42-
X_train, X_test, y_train, y_test = train_test_split(X, y,
43-
train_size=400,
44-
random_state=4)
42+
X_train, X_test, y_train, y_test = train_test_split(
43+
X, y, train_size=400, test_size=200, random_state=4)
4544

4645
max_depth = 30
4746
regr_multirf = MultiOutputRegressor(RandomForestRegressor(max_depth=max_depth,

examples/ensemble/plot_voting_decision_regions.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
# Training classifiers
4040
clf1 = DecisionTreeClassifier(max_depth=4)
4141
clf2 = KNeighborsClassifier(n_neighbors=7)
42-
clf3 = SVC(kernel='rbf', probability=True)
42+
clf3 = SVC(gamma=.1, kernel='rbf', probability=True)
4343
eclf = VotingClassifier(estimators=[('dt', clf1), ('knn', clf2),
4444
('svc', clf3)],
4545
voting='soft', weights=[2, 1, 2])

examples/model_selection/grid_search_text_feature_extraction.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
pipeline: ['vect', 'tfidf', 'clf']
2323
parameters:
2424
{'clf__alpha': (1.0000000000000001e-05, 9.9999999999999995e-07),
25-
'clf__n_iter': (10, 50, 80),
25+
'clf__max_iter': (10, 50, 80),
2626
'clf__penalty': ('l2', 'elasticnet'),
2727
'tfidf__use_idf': (True, False),
2828
'vect__max_n': (1, 2),
@@ -33,7 +33,7 @@
3333
Best score: 0.940
3434
Best parameters set:
3535
clf__alpha: 9.9999999999999995e-07
36-
clf__n_iter: 50
36+
clf__max_iter: 50
3737
clf__penalty: 'elasticnet'
3838
tfidf__use_idf: True
3939
vect__max_n: 2
@@ -97,14 +97,14 @@
9797
# increase processing time in a combinatorial way
9898
parameters = {
9999
'vect__max_df': (0.5, 0.75, 1.0),
100-
#'vect__max_features': (None, 5000, 10000, 50000),
100+
# 'vect__max_features': (None, 5000, 10000, 50000),
101101
'vect__ngram_range': ((1, 1), (1, 2)), # unigrams or bigrams
102-
#'tfidf__use_idf': (True, False),
103-
#'tfidf__norm': ('l1', 'l2'),
102+
# 'tfidf__use_idf': (True, False),
103+
# 'tfidf__norm': ('l1', 'l2'),
104104
'clf__max_iter': (5,),
105105
'clf__alpha': (0.00001, 0.000001),
106106
'clf__penalty': ('l2', 'elasticnet'),
107-
#'clf__n_iter': (10, 50, 80),
107+
# 'clf__max_iter': (10, 50, 80),
108108
}
109109

110110
if __name__ == "__main__":

0 commit comments

Comments
 (0)