Information Gain for a split
Beginner classical-mldecision-treessplitting-criteria
Implement:
def information_gain(
parent_labels: np.ndarray,
left_labels: np.ndarray,
right_labels: np.ndarray,
) -> float:
"""
parent_labels: labels of every sample in the node before splitting.
left_labels, right_labels: parent_labels partitioned by the
candidate split, every sample in exactly one of the two.
Returns:
how much the split reduces Gini impurity, a float.
"""
left_labels and right_labels together contain every sample in parent_labels, in some order, no sample is dropped or duplicated.
- Reuse
01-gini-impurity's gini_impurity rather than reimplementing it.