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

Skip to content

Commit 3f5f856

Browse files
antmarakisnorvig
authored andcommitted
Added Hamming Distance (#340)
In learning.py, I added the Hamming Distance metric.
1 parent ca02738 commit 3f5f856

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

learning.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ def manhattan_distance(predictions, targets):
3535
def mean_boolean_error(predictions, targets):
3636
return mean(int(p != t) for p, t in zip(predictions, targets))
3737

38+
def hamming_distance(predictions, targets):
39+
return sum(p != t for p, t in zip(predictions, targets))
40+
3841
# ______________________________________________________________________________
3942

4043

0 commit comments

Comments
 (0)