4 hidden checks

Implement the impurity measure and the split search a decision tree runs at every node.

  • gini(y): the Gini impurity of an array of integer class labels. Return 0.0 for an empty array.
  • best_split(x, y): for one feature x and labels y, return (threshold, score): the threshold t that minimises the weighted Gini of the two sides x < t and x >= t, and that weighted Gini. Only consider thresholds that put at least one example on each side; candidate thresholds are the unique values of x.
checks
  • gini of pure, balanced and empty nodesnot run
  • best_split separates a clean 1-D datasetnot run
  • best_split finds the classic iris splitnot run
  • best_split never leaves a side emptynot run
python sleeps until you press run

Press Run & check. Your code runs first, then the hidden checks on the left.