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

Skip to content

Commit e6c9b29

Browse files
committed
Tweak: use generator comprehension.
1 parent 0c0999f commit e6c9b29

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

learning.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def predict(example):
206206
"Find the k closest, and have them vote for the best."
207207
best = heapq.nsmallest(k, ((dataset.distance(e, example), e)
208208
for e in dataset.examples))
209-
return mode([e[dataset.target] for (d, e) in best])
209+
return mode(e[dataset.target] for (d, e) in best)
210210
return predict
211211

212212
#______________________________________________________________________________

0 commit comments

Comments
 (0)