I got 100% accuracy on my test set when trained using decision tree algorithm.but only got 85% accuracy on random forest
Is there something wrong with my model or is decision tree best suited for the dataset provided.
from sklearn.model_selection import train_test_split x_train, x_test, y_train, y_test = train_test_split(x, y, test_size=0.20) #Random Forest from sklearn.ensemble import RandomForestClassifier rf = RandomForestClassifier(n_estimators = 1000, random_state = 42) rf.fit(x_train, y_train); predictions = rf.predict(x_test) cm = sklearn.metrics.confusion_matrix(y_test,predictions) print(cm) #Decision Tree from sklearn import tree clf = tree.DecisionTreeClassifier() clf = clf.fit(x_train, y_train) predictions = clf.predict(x_test) cm = sklearn.metrics.confusion_matrix(y_test,predictions)
[[19937 1] [ 8 52]]
[[19938 0] [ 0 60]]