@@ -41,7 +41,7 @@ def plot_hyperplane(clf, min_x, max_x, linestyle, label):
41
41
# get the separating hyperplane
42
42
w = clf .coef_ [0 ]
43
43
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
45
45
yy = a * xx - (clf .intercept_ [0 ]) / w [1 ]
46
46
pl .plot (xx , yy , linestyle , label = label )
47
47
@@ -81,27 +81,28 @@ def plot_subfigure(X, Y, subplot, title, transform):
81
81
pl .xticks (())
82
82
pl .yticks (())
83
83
84
- if subplot == 1 :
84
+ if subplot == 2 :
85
+ pl .xlim (min_x - 5 , max_x )
85
86
pl .xlabel ('First principal component' )
86
87
pl .ylabel ('Second principal component' )
87
- pl .legend (loc = "upper right " )
88
+ pl .legend (loc = "upper left " )
88
89
89
90
90
- pl .figure (figsize = (13 , 6 ))
91
+ pl .figure (figsize = (8 , 6 ))
91
92
92
93
X , Y = make_multilabel_classification (n_classes = 2 , n_labels = 1 ,
93
94
allow_unlabeled = True ,
94
- random_state = 0 )
95
+ random_state = 1 )
95
96
96
97
plot_subfigure (X , Y , 1 , "With unlabeled samples + CCA" , "cca" )
97
98
plot_subfigure (X , Y , 2 , "With unlabeled samples + PCA" , "pca" )
98
99
7F86
99
100
X , Y = make_multilabel_classification (n_classes = 2 , n_labels = 1 ,
100
101
allow_unlabeled = False ,
101
- random_state = 0 )
102
+ random_state = 1 )
102
103
103
104
plot_subfigure (X , Y , 3 , "Without unlabeled samples + CCA" , "cca" )
104
105
plot_subfigure (X , Y , 4 , "Without unlabeled samples + PCA" , "pca" )
105
106
106
- pl .subplots_adjust (.04 , .07 , .97 , .90 , .09 , .2 )
107
+ pl .subplots_adjust (.04 , .02 , .97 , .94 , .09 , .2 )
107
108
pl .show ()
0 commit comments