Decision TreesEasy
Information Gain of a Split
~12 mincode completion
Implement information_gain(y, left) returning the gain in bits, where left is a 0/1 array marking the rows that go left.
Where this shows up
~12 min
••••••••••••••••
8 employers weight this skill
2 health and bio companies, 2 quant funds, 2 enterprise vendors, 1 AI product company, 1 frontier lab. Top match scores 87.
Python
import numpy as np
def information_gain(y, left):
"""
Entropy reduction (base 2) from splitting labels y.
Args:
y: array of shape (n,), class labels (any number of classes)
left: array of shape (n,), 1 if the row goes left, 0 if right
Returns:
float: H(parent) - (n_L/n) H(left) - (n_R/n) H(right)
"""
# YOUR CODE HERE
pass