def entropy(self, targets):
"""
Returns the entropy in the given rows.
:param targets: 1D array-like targets
:return: Float value of entropy
"""
results = self.unique_counts(targets)
ent = 0.0
for val in results.values():
p = float(val) / len(targets)
ent -= p * log2(p)
return ent
评论列表
文章目录