implementing decision tree algorithm gini index it is the name of the cost function that is used to evaluate the binary splits in the dataset and works with the categorial target variable "successor "failurehigher the value of gini indexhigher the homogeneity perfect gini index value is and worst is (for class problemgini index for split can be calculated with the help of following stepsfirstcalculate gini index for sub-nodes by using the formula ^ + ^ which is the sum of the square of probability for success and failure nextcalculate gini index for split using weighted gini score of each node of that split classification and regression tree (cartalgorithm uses gini method to generate binary splits split creation split is basically including an attribute in the dataset and value we can create split in dataset with the help of following three partspart calculating gini scorewe have just discussed this part in the previous section part splitting datasetit may be defined as separating dataset into two lists of rows having index of an attribute and split value of that attribute after getting the two groups right and leftfrom the datasetwe can calculate the value of split by using gini score calculated in first part split value will decide in which group the attribute will reside part evaluating all splitsnext part after finding gini score and splitting dataset is the evaluation of all splits for this purposefirstwe must check every value associated with each attribute as candidate split then we need to find the best possible split by evaluating the cost of the split the best split will be used as node in the decision tree building tree as we know that tree has root node and terminal nodes after creating the root nodewe can build the tree by following two partspart terminal node creation while creating terminal nodes of decision treeone important point is to decide when to stop growing tree or creating further terminal nodes it can be done by using two criteria namely maximum tree depth and minimum node records as followsmaximum tree depthas name suggeststhis is the maximum number of the nodes in tree after root node we must stop adding terminal nodes once tree