in [ ]from graphviz import source from sklearn import tree from ipython display import image graph source(tree export_graphviz(wqp_dtout_file=noneclass_names=wqp_label_namesfilled=truerounded=truespecial_ characters=falsefeature_names=wqp_feature_namesmax_depth= )png_data graph pipe(format='png'with open('dtree_structure png','wb'as ff write(png_dataimage(png_datafigure - visualizing our decision tree model our decision tree model has huge number of nodes and branches hence we visualized our tree for max depth of three based on the preceding snippet you can start observing the decision rules from the tree in figure - where the starting split is determined by the rule of alcohol <- and with each yes\no decision branch splitwe have further decision nodes as we descend into the tree at each depth level the class variable is what we are trying to predicti wine quality being lowmediumor high and value determines the total number of samples at each class present in the current decision node at each instance the gini parameter is basically the criterion which is used to determine and measure the quality of the split at each decision node best splits can be determined by metrics like gini impurity\gini index or information gain just to give you some contextthe gini impurity is metric that helps in minimizing the probability of misclassification it is usually mathematically denoted as followsc = = pi ( pi pi where we have classes to predictpi is the fraction of items labeled as class or the probability measure of instance with class label being chosen and ( piis the mistake in categorizing that item or misclassification measure the gini impurity\index is computed by summing the square of the fraction of classified instances for each class label in the classes and subtracting the result from interested readers can check out some standard literature on decision trees if interested in diving deeper into differences between entropy and gini or to understand more intricate mathematical details