Wakabayash1
Wakabayash1

Reputation: 11

Can gini and entropy accuracy values ​be the same in decision trees?

I created a decision tree in the codes I wrote on the Jupyter notebook. (with gini and entropy criteria) Then I made an accuracy calculation and created a report. However, in my transaction, report and accuracy were exactly the same. Is it possible or What would be the reason? Could you explain why and how? I made it for iris dataset. There are my codes;

classifierGini = DecisionTreeClassifier(criterion = "gini",
                                       random_state = 100)
classifierGini.fit(X_train, y_train)
display(graphviz.Source(tree.export_graphviz(classifierGini)))
y_pred_gini = prediction(X_test, classifierGini)
print("Confusion Matrix: \n" , confusion_matrix(y_test, y_pred_gini))
print("Accuracy :", accuracy_score(y_test, y_pred_gini))
print("Report: \n", classification_report(y_test, y_pred_gini))

Likewise for entropy and also here is my prediction function;

def prediction(X_test, classifier_object):
    y_pred_value = classifier_object.predict(X_test)
    print("Predicted values: ")
    print(y_pred_value)
    return y_pred_value

Upvotes: 1

Views: 264

Answers (0)

Related Questions