Entropy of a label sequence
(y)
| 220 | |
| 221 | |
| 222 | def 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 | |
| 231 | def gini(y): |
nothing calls this directly
no outgoing calls
no test coverage detected