def plot_2D_boundary(plot_range, points, decisionfcn, labels, values=[0]):
 clist = ['b', 'r', 'g', 'k', 'm', 'y']
 x = arange(plot_range[0], plot_range[1], 0.1)
 y = arange(plot_range[2], plot_range[3], 0.1)
 (xx, yy) = meshgrid(x, y)
 (xxx, yyy) = (xx.flatten(), yy.flatten())
 zz = array(decisionfcn(xxx, yyy))
 zz = zz.reshape(xx.shape)
 contour(xx, yy, zz, values)
 for i in range(len(points)):
  d = decisionfcn(points[i][:, 0], points[i][:, 1])
  correct_ndx = (labels[i] == d)
  incorrect_ndx = (labels[i] != d)
  plot(points[i][(correct_ndx, 0)], points[i][(correct_ndx, 1)], '*', color=clist[i])
  plot(points[i][(incorrect_ndx, 0)], points[i][(incorrect_ndx, 1)], 'o', color=clist[i])
 axis('equal')

def plot_2D_boundary ( plot_range , points , decisionfcn , labels , values = [ 0 ] ) : clist = [ 'b' , 'r' , 'g' , 'k' , 'm' , 'y' ] x = arange ( plot_range [ 0 ] , plot_range [ 1 ] , 0.1 ) y = arange ( plot_range [ 2 ] , plot_range [ 3 ] , 0.1 ) ( xx , yy ) = meshgrid ( x , y ) ( xxx , yyy ) = ( xx . flatten ( ) , yy . flatten ( ) ) zz = array ( decisionfcn ( xxx , yyy ) ) zz = zz . reshape ( xx . shape ) contour ( xx , yy , zz , values ) for i in range ( len ( points ) ) : d = decisionfcn ( points [ i ] [ : , 0 ] , points [ i ] [ : , 1 ] ) correct_ndx = ( labels [ i ] == d ) incorrect_ndx = ( labels [ i ] != d ) plot ( points [ i ] [ ( correct_ndx , 0 ) ] , points [ i ] [ ( correct_ndx , 1 ) ] , '*' , color = clist [ i ] ) plot ( points [ i ] [ ( incorrect_ndx , 0 ) ] , points [ i ] [ ( incorrect_ndx , 1 ) ] , 'o' , color = clist [ i ] ) axis ( 'equal' )
plot_range is .