Using Gini index, how to calculate the probability of correctly classifying a new randomly selected case to the highest probability class?
While you can calculate the underlying class probabilities from the Gini index (for binary classification), it'll be more straightforward to calculate it from the &quot;value&quot; line in each box. This line simply represents the number of samples that belong in each node, split by the target variable, so you can use this count to calculate a probability.
In the bottom-most node, for example, you have value = [4, 55], indicating that among 59 samples which belong in that node (samples that have ca &gt; 0.5 and cp_4.0 &gt; 0.5), 4 are No HD and 55 are Yes HD. Therefore, the probability of Yes HD in that node is 55/59.
The Gini index is a measure of how &quot;pure&quot; a node is - as this number gets closer to 0, probability values will become more extreme (closer to 0 or 1), indicating that the decision tree is doing a better job of discriminating the target variable.