Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 274b629

Browse files
committed
Tweaked information_content().
1 parent 8cfb62d commit 274b629

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

learning.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -317,9 +317,8 @@ def split_by(attr, examples):
317317

318318
def information_content(values):
319319
"Number of bits to represent the probability distribution in values."
320-
# If the values do not sum to 1, normalize them to make them a Prob. Dist.
321-
values = normalize(removeall(0, values))
322-
return sum([- v * log2(v) for v in values])
320+
probabilities = normalize(removeall(0, values))
321+
return sum(-p * log2(p) for p in probabilities)
323322

324323
#______________________________________________________________________________
325324

0 commit comments

Comments
 (0)