accuracy on training set accuracy on test set analyzing decision trees we can visualize the tree using the export_graphviz function from the tree module this writes file in the dot file formatwhich is text file format for storing graphs we set an option to color the nodes to reflect the majority class in each node and pass the class and features names so the tree can be properly labeledin[ ]from sklearn tree import export_graphviz export_graphviz(treeout_file="tree dot"class_names=["malignant""benign"]feature_names=cancer feature_namesimpurity=falsefilled=truewe can read this file and visualize itas seen in figure - using the graphviz module (or you can use any program that can read dot files)in[ ]import graphviz with open("tree dot"as fdot_graph read(graphviz source(dot_graphfigure - visualization of the decision tree built on the breast cancer dataset supervised learning