<s> import matplotlib <EOL> import numpy as np <EOL> import matplotlib . cm as cm <EOL> import matplotlib . mlab as mlab <EOL> import matplotlib . pyplot as plt <EOL> from matplotlib import ticker <EOL> import pylab <EOL> def gridplot ( classifieur , train , test , n_points = <NUM_LIT:50> ) : <EOL> train_test = np . vstack ( ( train , test ) ) <EOL> ( min_x1 , max_x1 ) = ( min ( train_test [ : , <NUM_LIT:0> ] ) , max ( train_test [ : , <NUM_LIT:0> ] ) ) <EOL> ( min_x2 , max_x2 ) = ( min ( train_test [ : , <NUM_LIT:1> ] ) , max ( train_test [ : , <NUM_LIT:1> ] ) ) <EOL> xgrid = np . linspace ( min_x1 , max_x1 , num = n_points ) <EOL> ygrid = np . linspace ( min_x2 , max_x2 , num = n_points ) <EOL> thegrid = np . array ( combine ( xgrid , ygrid ) ) <EOL> les_sorties = classifieur . compute_predictions ( thegrid ) <EOL> classesPred = np . sign ( les_sorties ) <EOL> pylab . scatter ( thegrid [ : , <NUM_LIT:0> ] , thegrid [ : , <NUM_LIT:1> ] , c = classesPred , s = <NUM_LIT:50> ) <EOL> pylab . scatter ( train [ : , <NUM_LIT:0> ] , train [ : , <NUM_LIT:1> ] , c = train [ : , - <NUM_LIT:1> ] , marker = '<STR_LIT:v>' , s = <NUM_LIT:50> ) <EOL> pylab . scatter ( test [ : , <NUM_LIT:0> ] , test [ : , <NUM_LIT:1> ] , c = test [ : , - <NUM_LIT:1> ] , marker = '<STR_LIT:s>' , s = <NUM_LIT:50> ) <EOL> h1 = pylab . plot ( [ min_x1 ] , [ min_x2 ] , marker = '<STR_LIT:o>' , c = '<STR_LIT:w>' , ms = <NUM_LIT:5> ) <EOL> h2 = pylab . plot ( [ min_x1 ] , [ min_x2 ] , marker = '<STR_LIT:v>' , c = '<STR_LIT:w>' , ms = <NUM_LIT:5> ) <EOL> h3 = pylab . plot ( [ min_x1 ] , [ min_x2 ] , marker = '<STR_LIT:s>' , c = '<STR_LIT:w>' , ms = <NUM_LIT:5> ) <EOL> handles = [ h1 , h2 , h3 ] <EOL> pylab . axis ( '<STR_LIT>' ) <EOL> pylab . show ( ) <EOL> def combine ( * seqin ) : <EOL> '''<STR_LIT>''' <EOL> def rloop ( seqin , listout , comb ) : <EOL> '''<STR_LIT>''' <EOL> if seqin : <EOL> for item in seqin [ <NUM_LIT:0> ] : <EOL> newcomb = comb + [ item ] <EOL> rloop ( seqin [ <NUM_LIT:1> : ] , listout , newcomb ) <EOL> else : <EOL> listout . append ( comb ) <EOL> listout = [ ] <EOL> rloop ( seqin , listout , [ ] ) <EOL> return listout </s>
