Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.14 KB | None | 0 0
  1. import csv
  2. import sys
  3.  
  4. #This is matching script you can use locally for testing your output format
  5.  
  6. def check(file1,file2):
  7. labels_true=[]
  8. labels_predicted=[]
  9. with open(file1) as csv_file:
  10. csv_reader = csv.reader(csv_file, delimiter=',')
  11. line_count = 0
  12. for row in csv_reader:
  13. if line_count != 0 and row!=[]:
  14. labels_true.append(row[0])
  15. line_count += 1
  16. total_lines = line_count
  17.  
  18. with open(file2) as csv_file:
  19. cnt = 0
  20. csv_reader = csv.reader(csv_file, delimiter=',')
  21. line_count = 0
  22. for row in csv_reader:
  23. if line_count != 0 and row!=[]:
  24. labels_predicted.append(row[0])
  25. line_count += 1
  26. #Process only the lines for which there is something in the input!|
  27.  
  28.  
  29. correct=0
  30. for i in range(len(labels_true)):
  31. if labels_true[i]==labels_predicted[i]:
  32. correct+=1
  33. return int((correct/len(labels_true))*100)
  34.  
  35. f1 = sys.argv[1] #Actual File
  36. f2 = sys.argv[2] #Predictions File
  37. #f1='./Solution.csv'
  38. #f2='./Solution.csv'
  39. print(check(f1,f2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement