#******** Instruction # # 1. Please install library via anaconda navigator # # # conda install -c conda-forge pydotplus # # 2. Please run the below code by highlight and click the run cell. # #*********************************************************************************** #Generate dataset, 2 dimesniion/features/variables, 4 classes/labels from sklearn.datasets import make_blobs X, y = make_blobs(n_samples=300, centers=4, random_state=0, cluster_std=1.0) #********************************************************************************** #Create Decision Tree Model from sklearn.tree import DecisionTreeClassifier tree = DecisionTreeClassifier().fit(X, y) #********************************************************************************** #Create plot tree method from sklearn.externals.six import StringIO from IPython.display import Image from sklearn.tree import export_graphviz import pydotplus dot_data = StringIO() export_graphviz(tree, out_file=dot_data, filled=True, rounded=True, special_characters=True) graph = pydotplus.graph_from_dot_data(dot_data.getvalue()) Image(graph.create_png())