我的決策樹準確性達到100%。我在做什麼錯了?
這是我的代碼:
將pandas導入為pd
導入json
將numpy導入為np
導入sklearn
導入matplotlib.pyplot作為plt
數據= np.loadtxt(“ / Users / Nadjla / Downloads / allInteractionsnum.csv”,delimiter =',')
x =數據[0:14]
y =數據[-1]
從sklearn.cross_validation導入train_test_split
x_train = x [0:2635]
x_test = x [0:658]
y_train = y [0:2635]
y_test = y [0:658]
從sklearn.tree導入DecisionTreeClassifier
樹= DecisionTreeClassifier()
tree.fit(x_train.astype(int),y_train.astype(int))
從sklearn.metrics導入precision_score
y_predicted = tree.predict(x_test.astype(int))
precision_score(y_test.astype(int),y_predicted)