SHARE
TWEET

Fellos

a guest Mar 26th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. from pandas import read_csv
  2. from numpy import zeros
  3. from sklearn.model_selection import train_test_split
  4. from matplotlib.pyplot import plot,subplot
  5.  
  6.  
  7. data=read_csv("http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data", header=None).values
  8. NumberOfPatterns=data.shape[0]
  9. NumberOfAttributes=data.shape[1]
  10. mdict ={'Iris-setosa': 0, 'Iris-versicolor':1, 'Iris-virginica':0}
  11.  
  12. x =data[:,0:4]
  13. t =zeros(NumberOfPatterns)
  14.  
  15. for ptrn in range(NumberOfPatterns):
  16.     t[ptrn] = mdict[data[ptrn,4]]
  17. for i in range(9):
  18.     xtrain, xtest, ttrain, ytest = train_test_split(x,t,test_size=0.1)
  19.     subplot(3,3,i+1)
  20.     plot(xtrain[:,0],xtrain[:,2],'bo')
  21.     plot(xtest[:,0],xtest[:,2],'ro')
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top