1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24
|
X = [[181, 80, 44], [177, 70, 43], [160, 60, 38], [154, 54, 37], [166, 65, 40], [190, 90, 47], [175, 64, 39], [177, 70, 40], [159, 55, 38], [171, 75, 42], [181, 85, 43], [148, 70, 42]]
y = ['male', 'female', 'female', 'female', 'female', 'female', 'female', 'female', 'male', 'female', 'male', 'male']
"""选择决策树算法,训练算法""" from sklearn import tree try: with open('DecisionTree.pickle', 'rb') as f: clf = pickle.load(f) except Exception, e: clf = tree.DecisionTreeClassifier() clf.fit(X, y)
with open('DecisionTree.pickle', 'wb') as f: import pickle pickle.dump(clf, f)
|