8000 ENHanced the multilabel example aspect · seckcoder/scikit-learn@2f79cb2 · GitHub
[go: up one dir, main page]

Skip to content

Commit 2f79cb2

Browse files
veneGaelVaroquaux
authored andcommitted
ENHanced the multilabel example aspect
1 parent a3df4fb commit 2f79cb2

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

examples/plot_multilabel.py

Lines changed: 8 additions & 7 deletions
7F86
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ def plot_hyperplane(clf, min_x, max_x, linestyle, label):
4141
# get the separating hyperplane
4242
w = clf.coef_[0]
4343
a = -w[0] / w[1]
44-
xx = np.linspace(min_x, max_x)
44+
xx = np.linspace(min_x - 5, max_x + 5) # make sure the line is long enough
4545
yy = a * xx - (clf.intercept_[0]) / w[1]
4646
pl.plot(xx, yy, linestyle, label=label)
4747

@@ -81,27 +81,28 @@ def plot_subfigure(X, Y, subplot, title, transform):
8181
pl.xticks(())
8282
pl.yticks(())
8383

84-
if subplot == 1:
84+
if subplot == 2:
85+
pl.xlim(min_x - 5, max_x)
8586
pl.xlabel('First principal component')
8687
pl.ylabel('Second principal component')
87-
pl.legend(loc="upper right")
88+
pl.legend(loc="upper left")
8889

8990

90-
pl.figure(figsize=(13, 6))
91+
pl.figure(figsize=(8, 6))
9192

9293
X, Y = make_multilabel_classification(n_classes=2, n_labels=1,
9394
allow_unlabeled=True,
94-
random_state=0)
95+
random_state=1)
9596

9697
plot_subfigure(X, Y, 1, "With unlabeled samples + CCA", "cca")
9798
plot_subfigure(X, Y, 2, "With unlabeled samples + PCA", "pca")
9899

99100
X, Y = make_multilabel_classification(n_classes=2, n_labels=1,
100101
allow_unlabeled=False,
101-
random_state=0)
102+
random_state=1)
102103

103104
plot_subfigure(X, Y, 3, "Without unlabeled samples + CCA", "cca")
104105
plot_subfigure(X, Y, 4, "Without unlabeled samples + PCA", "pca")
105106

106-
pl.subplots_adjust(.04, .07, .97, .90, .09, .2)
107+
pl.subplots_adjust(.04, .02, .97, .94, .09, .2)
107108
pl.show()

0 commit comments

Comments
 (0)
0