Guest User

Untitled

a guest
Nov 23rd, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.97 KB | None | 0 0
  1. import numpy as np
  2. from sklearn import tree
  3. import matplotlib.pyplot as plt
  4.  
  5.  
  6.  
  7. greyhounds = 500
  8. labs = 500
  9.  
  10. labels = [0,1]
  11. grey_height = 28 + 4 * np.random.randn(greyhounds)
  12. lab_height = 24 + 4* np.random.randn(labs)
  13.  
  14. grey_weight = 90 + 12* np.random.randn(greyhounds)
  15. lab_weight = 120 + 12* np.random.randn(labs)
  16. grey_height1 = grey_height[0]
  17. grey_height2 = grey_height[1]
  18. grey_weight1 = grey_weight[0]
  19. grey_weight2 = grey_weight[1]
  20.  
  21. lab_height1 = lab_height[0]
  22. lab_height2 = lab_height[1]
  23. lab_weight1 = lab_weight[0]
  24. lab_weight2 = lab_weight[1]
  25.  
  26. features = [[grey_height1,grey_weight1],[grey_height2,grey_weight2],[lab_height1,lab_weight1],[lab_height2,lab_weight2]]
  27. labels = [0,0,1,1]
  28.  
  29. classifier = tree.DecisionTreeClassifier()
  30. classifier = classifier.fit(features, labels)
  31. print (classifier.predict([[31.2345,96.236754653]]))
  32. #print ([grey_height[0], grey_weight[0]], [grey_height[1],grey_weight[1]])
  33.  
  34. #plt.hist([grey_height, lab_height], stacked = False, color = ['r', 'b'])
  35. #plt.show()
Add Comment
Please, Sign In to add comment