Build a decision tree classifier using scikit-learn's code example
Example 1: scikit decision tree classifier gini criterion
from sklearn.tree import DecisionTreeClassifier
from sklearn import metrics
clf_gini_max = DecisionTreeClassifier(random_state=50, criterion='gini', max_depth=None)
clf_gini_max = clf_gini_max.fit(X_train,Y_train)
Y_pred = clf_gini_max.predict(X_test)
training_accuracy = clf_gini_max.score(X_train,Y_train)
testing_accuracy = clf_gini_max.score(X_test,Y_test)
print(training_accuracy)
print(testing_accuracy)
Example 2: skit learn decision
import graphviz
dot_data = tree.export_graphviz(clf, out_file=None)
graph = graphviz.Source(dot_data)
graph.render("iris")