我的决策树准确性达到100%。我究竟做错了什么?
这是我的代码:
import pandas as pd
import json
import numpy as np
import sklearn
import matplotlib.pyplot as plt
data = np.loadtxt("/Users/Nadjla/Downloads/allInteractionsnum.csv", delimiter=',')
x = data[0:14]
y = data[-1]
from sklearn.cross_validation import train_test_split
x_train = x[0:2635]
x_test = x[0:658]
y_train = y[0:2635]
y_test = y[0:658]
from sklearn.tree import DecisionTreeClassifier
tree = DecisionTreeClassifier()
tree.fit(x_train.astype(int), y_train.astype(int))
from sklearn.metrics import accuracy_score
y_predicted = tree.predict(x_test.astype(int))
accuracy_score(y_test.astype(int), y_predicted)