Loading...
Compute the information gain from splitting a dataset.
Given a parent set of labels and the labels in two child subsets after a split, compute:
IG=H(parent)−∣parent∣∣left∣H(left)−∣parent∣∣right∣H(right)
where H is the entropy: H=−∑k=1Kpklog2(pk)
Use 0log2(0)=0 by convention. Return the information gain rounded to 4 decimal places.
parent = [1, 1, 0, 0] left = [1, 1] right = [0, 0]
1.0