Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- from sklearn import tree
- import matplotlib.pyplot as plt
- greyhounds = 500
- labs = 500
- labels = [0,1]
- grey_height = 28 + 4 * np.random.randn(greyhounds)
- lab_height = 24 + 4* np.random.randn(labs)
- grey_weight = 90 + 12* np.random.randn(greyhounds)
- lab_weight = 120 + 12* np.random.randn(labs)
- grey_height1 = grey_height[0]
- grey_height2 = grey_height[1]
- grey_weight1 = grey_weight[0]
- grey_weight2 = grey_weight[1]
- lab_height1 = lab_height[0]
- lab_height2 = lab_height[1]
- lab_weight1 = lab_weight[0]
- lab_weight2 = lab_weight[1]
- features = [[grey_height1,grey_weight1],[grey_height2,grey_weight2],[lab_height1,lab_weight1],[lab_height2,lab_weight2]]
- labels = [0,0,1,1]
- classifier = tree.DecisionTreeClassifier()
- classifier = classifier.fit(features, labels)
- print (classifier.predict([[31.2345,96.236754653]]))
- #print ([grey_height[0], grey_weight[0]], [grey_height[1],grey_weight[1]])
- #plt.hist([grey_height, lab_height], stacked = False, color = ['r', 'b'])
- #plt.show()
Add Comment
Please, Sign In to add comment