3232print (__doc__ )
3333
3434import numpy as np
35- import matplotlib .pylab as pl
35+ import matplotlib .pyplot as plt
3636
3737from sklearn .datasets import make_multilabel_classification
3838from sklearn .multiclass import OneVsRestClassifier
@@ -48,7 +48,7 @@ def plot_hyperplane(clf, min_x, max_x, linestyle, label):
4848 a = - w [0 ] / w [1 ]
4949 xx = np .linspace (min_x - 5 , max_x + 5 ) # make sure the line is long enough
5050 yy = a * xx - (clf .intercept_ [0 ]) / w [1 ]
51- pl .plot (xx , yy , linestyle , label = label )
51+ plt .plot (xx , yy , linestyle , label = label )
5252
5353
5454def plot_subfigure (X , Y , subplot , title , transform ):
@@ -68,33 +68,33 @@ def plot_subfigure(X, Y, subplot, title, transform):
6868 classif = OneVsRestClassifier (SVC (kernel = 'linear' ))
6969 classif .fit (X , Y )
7070
71- pl .subplot (2 , 2 , subplot )
72- pl .title (title )
71+ plt .subplot (2 , 2 , subplot )
72+ plt .title (title )
7373
7474 zero_class = np .where (Y [:, 0 ])
7575 one_class = np .where (Y [:, 1 ])
76- pl .scatter (X [:, 0 ], X [:, 1 ], s = 40 , c = 'gray' )
77- pl .scatter (X [zero_class , 0 ], X [zero_class , 1 ], s = 160 , edgecolors = 'b' ,
76+ plt .scatter (X [:, 0 ], X [:, 1 ], s = 40 , c = 'gray' )
77+ plt .scatter (X [zero_class , 0 ], X [zero_class , 1 ], s = 160 , edgecolors = 'b' ,
7878 facecolors = 'none' , linewidths = 2 , label = 'Class 1' )
79- pl .scatter (X [one_class , 0 ], X [one_class , 1 ], s = 80 , edgecolors = 'orange' ,
79+ plt .scatter (X [one_class , 0 ], X [one_class , 1 ], s = 80 , edgecolors = 'orange' ,
8080 facecolors = 'none' , linewidths = 2 , label = 'Class 2' )
8181
8282 plot_hyperplane (classif .estimators_ [0 ], min_x , max_x , 'k--' ,
8383 'Boundary\n for class 1' )
8484 plot_hyperplane (classif .estimators_ [1 ], min_x , max_x , 'k-.' ,
8585 'Boundary\n for class 2' )
86- pl .xticks (())
87- pl .yticks (())
86+ plt .xticks (())
87+ plt .yticks (())
8888
89- pl .xlim (min_x - .5 * max_x , max_x + .5 * max_x )
90- pl .ylim (min_y - .5 * max_y , max_y + .5 * max_y )
89+ plt .xlim (min_x - .5 * max_x , max_x + .5 * max_x )
90+ plt .ylim (min_y - .5 * max_y , max_y + .5 * max_y )
9191 if subplot == 2 :
92- pl .xlabel ('First principal component' )
93- pl .ylabel ('Second principal component' )
94- pl .legend (loc = "upper left" )
92+ plt .xlabel ('First principal component' )
93+ plt .ylabel ('Second principal component' )
94+ plt .legend (loc = "upper left" )
9595
9696
97- pl .figure (figsize = (8 , 6 ))
97+ plt .figure (figsize = (8 , 6 ))
9898
9999X , Y = make_multilabel_classification (n_classes = 2 , n_labels = 1 ,
100100 allow_unlabeled = True ,
@@ -112,5 +112,5 @@ def plot_subfigure(X, Y, subplot, title, transform):
112112plot_subfigure (X , Y , 3 , "Without unlabeled samples + CCA" , "cca" )
113113plot_subfigure (X , Y , 4 , "Without unlabeled samples + PCA" , "pca" )
114114
115- pl .subplots_adjust (.04 , .02 , .97 , .94 , .09 , .2 )
116- pl .show ()
115+ plt .subplots_adjust (.04 , .02 , .97 , .94 , .09 , .2 )
116+ plt .show ()
0 commit comments