Skip to content

Instantly share code, notes, and snippets.

@Deepayan137
Created January 1, 2019 16:25
Show Gist options
  • Save Deepayan137/853df7b6543c3ac7c05423f2cacf4f6e to your computer and use it in GitHub Desktop.
Save Deepayan137/853df7b6543c3ac7c05423f2cacf4f6e to your computer and use it in GitHub Desktop.
Character accuracy
import Levenshtein as lev
def cer(prediction, target):
sum_edit_dists = lev.distance(prediction, target)
sum_gt_lengths = sum(map(len, target))
fraction = sum_edit_dists/sum_gt_lengths
percent = fraction*100
return (100.0-percent)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment