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)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy