MCPcopy Create free account
hub / github.com/ddbourgin/numpy-ml / gini

Function gini

numpy_ml/trees/dt.py:231–237  ·  view source on GitHub ↗

Gini impurity (local entropy) of a label sequence

(y)

Source from the content-addressed store, hash-verified

229
230
231def gini(y):
232 """
233 Gini impurity (local entropy) of a label sequence
234 """
235 hist = np.bincount(y)
236 N = np.sum(hist)
237 return 1 - sum([(i / N) ** 2 for i in hist])

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected