Advertisement
Guest User

Untitled

a guest
Mar 25th, 2019
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 KB | None | 0 0
  1. import pandas as pd
  2. import numpy as np
  3. from sklearn.model_selection import train_test_split
  4. from matplotlib.pyplot import plot,subplot
  5. data = pd.read_csv("http://archive.ics.uci.edu/ml/machine-learning-databases/iris/iris.data", header=None).values
  6.  
  7. NoP = data.shape[0]
  8. NoA = data.shape[1]
  9.  
  10. map_dict = {'Iris-setosa': 0, 'Iris-versicolor':1, 'Iris-virginica':0}
  11.  
  12. x = data[:,0:4]
  13. t = np.zeros(NoP)
  14.  
  15. for pattern in range(NoP):
  16. t[pattern] = map_dict[data[pattern,4]]
  17.  
  18.  
  19.  
  20. for i in range(1,10):
  21. xTrain, xTest, tTrain, yTest = train_test_split(x,t,test_size=0.1)
  22. subplot(3,3,i)
  23. plot(xTrain[:,0],xTrain[:,2],'bo')
  24. plot(xTest[:,0],xTest[:,2],'ro')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement