Thanks to visit codestin.com Credit goes to github.com
We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 9639eed commit 8cfb62dCopy full SHA for 8cfb62d
learning.py
@@ -299,13 +299,13 @@ def choose_attribute(attrs, examples):
299
lambda a: information_gain(a, examples))
300
301
def information_gain(attr, examples):
302
+ "Return the expected reduction in entropy from splitting by attr."
303
def I(examples):
304
return information_content([count(target, v, examples)
305
for v in values[target]])
306
N = float(len(examples))
- remainder = 0
307
- for (v, examples_i) in split_by(attr, examples):
308
- remainder += (len(examples_i) / N) * I(examples_i)
+ remainder = sum((len(examples_i) / N) * I(examples_i)
+ for (v, examples_i) in split_by(attr, examples))
309
return I(examples) - remainder
310
311
def split_by(attr, examples):
0 commit comments