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

Function entropy

numpy_ml/trees/dt.py:222–228  ·  view source on GitHub ↗

Entropy of a label sequence

(y)

Source from the content-addressed store, hash-verified

220
221
222def entropy(y):
223 """
224 Entropy of a label sequence
225 """
226 hist = np.bincount(y)
227 ps = hist / np.sum(hist)
228 return -np.sum([p * np.log2(p) for p in ps if p > 0])
229
230
231def gini(y):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected