Advertisement
Guest User

Untitled

a guest
Jan 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. with open("output_dev_20k","r") as f:
  2. output = f.read().split('\n')
  3.  
  4.  
  5. with open("tst2012.from","r") as f:
  6. from_data = f.read().split('\n')
  7.  
  8. right = 0
  9. total = 0
  10.  
  11. for n,_ in enumerate(output):
  12. try:
  13. num_1 = float(from_data[n].split(' +')[0])
  14. num_2 = float(from_data[n].split('+ ')[1])
  15. real_answer = num_1 + num_2
  16. predicted_answer = float(output[n])
  17.  
  18. if predicted_answer == real_answer:
  19. right+=1
  20. total+=1
  21. print(real_answer, predicted_answer)
  22. except Exception as e:
  23. print(str(e))
  24.  
  25. print(right/total)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement