1. 程式人生 > >簡單的決策樹

簡單的決策樹

pri int ora print 分類 style sklearn class fit

1 #簡單的決策樹分類
2 from sklearn import tree
3 features = [[300,2],[450,2],[200,8],[150,9]]
4 labels = [apple,apple,orange,orange]
5 clf = tree.DecisionTreeClassifier()
6 clf = clf.fit(features,labels)
7 print(clf.predict([[400,6]]))

簡單的決策樹