Skip to content

Commit b9c2433

Browse files
committed
Fix some pyflakes complaints.
1 parent 19ca12f commit b9c2433

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

learning.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,10 @@
1111
import math
1212
import random
1313

14-
from statistics import mean
14+
# XXX statistics.mode is not quite the same as the old utils.mode:
15+
# it insists on there being a unique most-frequent value. Code using mode
16+
# needs to be revisited, or we need to restore utils.mode.
17+
from statistics import mean, mode
1518
from collections import defaultdict
1619

1720
# ______________________________________________________________________________
@@ -391,7 +394,7 @@ def split_by(attr, examples):
391394
def information_content(values):
392395
"Number of bits to represent the probability distribution in values."
393396
probabilities = normalize(removeall(0, values))
394-
return sum(-p * log2(p) for p in probabilities)
397+
return sum(-p * math.log2(p) for p in probabilities)
395398

396399
# ______________________________________________________________________________
397400

@@ -439,7 +442,6 @@ def NeuralNetLearner(dataset, hidden_layer_sizes=[3],
439442
epoches: Number of passes over the dataset
440443
"""
441444

442-
examples = dataset.examples
443445
i_units = len(dataset.inputs)
444446
o_units = 1 # As of now, dataset.target gives only one index.
445447

@@ -586,7 +588,6 @@ def BackPropagationLearner(dataset, net, learning_rate, epoches):
586588

587589
def PerceptronLearner(dataset, learning_rate=0.01, epoches=100):
588590
"""Logistic Regression, NO hidden layer"""
589-
examples = dataset.examples
590591
i_units = len(dataset.inputs)
591592
o_units = 1 # As of now, dataset.target gives only one index.
592593
hidden_layer_sizes = []

0 commit comments

Comments
 (0)