NumPy allowed · plain Python earns 10 bonus points
Calculate the Gini impurity metric for a set of categorical target labels.
Implement gini_impurity(labels): compute Gini impurity 1.0 - sum((count_k / N)**2). Return 0.0 for empty input. Round float to 4 decimal places.
gini_impurity(labels: list[any]) -> float