Guest User

Untitled

a guest
Jul 22nd, 2018
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. from matplotlib.colors import ListedColormap
  2.  
  3. xset,yset = xtrain,ytrain
  4.  
  5. x1,x2 = np.meshgrid(np.arange(start = xset[:,0].min()-1,stop = xset[:,0].max()+1,step = .01),np.arange(start = xset[:,1].min()-1,stop = xset[:,1].max()+1,step = .01))
  6.  
  7. plt.contourf(x1,x2,classifier.predict(np.array([x1.ravel(),x2.ravel()]).T).reshape(x1.shape),alpha=.75,cmap = ListedColormap(('red','green')))
  8.  
  9. for i,j in enumerate(np.unique(yset)):
  10. plt.scatter(xset[yset==j,0],xset[yset==j,1],cmap=ListedColormap(('red','green'))(i),label = j,marker='+')
  11.  
  12. plt.xlabel('Age')
  13.  
  14. plt.ylabel('Estimated Salary')
  15.  
  16. plt.show()
Add Comment
Please, Sign In to add comment