Skip to content

Commit 4d749ea

Browse files
thomasjpfanqinhanmin2014
authored andcommitted
CLN Uses public API instead of deprecated modules in examples (scikit-learn#15390)
1 parent 7c47337 commit 4d749ea

5 files changed

+11
-13
lines changed

examples/gaussian_process/plot_gpc.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
from matplotlib import pyplot as plt
3232

33-
from sklearn.metrics.classification import accuracy_score, log_loss
33+
from sklearn.metrics import accuracy_score, log_loss
3434
from sklearn.gaussian_process import GaussianProcessClassifier
3535
from sklearn.gaussian_process.kernels import RBF
3636

examples/semi_supervised/plot_label_propagation_digits.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class will be very good.
2525
from scipy import stats
2626

2727
from sklearn import datasets
28-
from sklearn.semi_supervised import label_propagation
28+
from sklearn.semi_supervised import LabelSpreading
2929

3030
from sklearn.metrics import confusion_matrix, classification_report
3131

@@ -52,7 +52,7 @@ class will be very good.
5252

5353
# #############################################################################
5454
# Learn with LabelSpreading
55-
lp_model = label_propagation.LabelSpreading(gamma=.25, max_iter=20)
55+
lp_model = LabelSpreading(gamma=.25, max_iter=20)
5656
lp_model.fit(X, y_train)
5757
predicted_labels = lp_model.transduction_[unlabeled_set]
5858
true_labels = y[unlabeled_set]

examples/semi_supervised/plot_label_propagation_digits_active_learning.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
from scipy import stats
2929

3030
from sklearn import datasets
31-
from sklearn.semi_supervised import label_propagation
31+
from sklearn.semi_supervised import LabelSpreading
3232
from sklearn.metrics import classification_report, confusion_matrix
3333

3434
digits = datasets.load_digits()
@@ -54,7 +54,7 @@
5454
y_train = np.copy(y)
5555
y_train[unlabeled_indices] = -1
5656

57-
lp_model = label_propagation.LabelSpreading(gamma=0.25, max_iter=20)
57+
lp_model = LabelSpreading(gamma=0.25, max_iter=20)
5858
lp_model.fit(X, y_train)
5959

6060
predicted_labels = lp_model.transduction_[unlabeled_indices]

examples/semi_supervised/plot_label_propagation_structure.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
import numpy as np
1919
import matplotlib.pyplot as plt
20-
from sklearn.semi_supervised import label_propagation
20+
from sklearn.semi_supervised import LabelSpreading
2121
from sklearn.datasets import make_circles
2222

2323
# generate ring with inner box
@@ -30,7 +30,7 @@
3030

3131
# #############################################################################
3232
# Learn with LabelSpreading
33-
label_spread = label_propagation.LabelSpreading(kernel='knn', alpha=0.8)
33+
label_spread = LabelSpreading(kernel='knn', alpha=0.8)
3434
label_spread.fit(X, labels)
3535

3636
# #############################################################################

examples/semi_supervised/plot_label_propagation_versus_svm_iris.py

+4-6
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
import matplotlib.pyplot as plt
2020
from sklearn import datasets
2121
from sklearn import svm
22-
from sklearn.semi_supervised import label_propagation
22+
from sklearn.semi_supervised import LabelSpreading
2323

2424
rng = np.random.RandomState(0)
2525

@@ -37,11 +37,9 @@
3737
y_50[rng.rand(len(y)) < 0.5] = -1
3838
# we create an instance of SVM and fit out data. We do not scale our
3939
# data since we want to plot the support vectors
40-
ls30 = (label_propagation.LabelSpreading().fit(X, y_30),
41-
y_30)
42-
ls50 = (label_propagation.LabelSpreading().fit(X, y_50),
43-
y_50)
44-
ls100 = (label_propagation.LabelSpreading().fit(X, y), y)
40+
ls30 = (LabelSpreading().fit(X, y_30), y_30)
41+
ls50 = (LabelSpreading().fit(X, y_50), y_50)
42+
ls100 = (LabelSpreading().fit(X, y), y)
4543
rbf_svc = (svm.SVC(kernel='rbf', gamma=.5).fit(X, y), y)
4644

4745
# create a mesh to plot in

0 commit comments

Comments
 (0)