Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import csv
- import sys
- #This is matching script you can use locally for testing your output format
- def check(file1,file2):
- labels_true=[]
- labels_predicted=[]
- with open(file1) as csv_file:
- csv_reader = csv.reader(csv_file, delimiter=',')
- line_count = 0
- for row in csv_reader:
- if line_count != 0 and row!=[]:
- labels_true.append(row[0])
- line_count += 1
- total_lines = line_count
- with open(file2) as csv_file:
- cnt = 0
- csv_reader = csv.reader(csv_file, delimiter=',')
- line_count = 0
- for row in csv_reader:
- if line_count != 0 and row!=[]:
- labels_predicted.append(row[0])
- line_count += 1
- #Process only the lines for which there is something in the input!|
- correct=0
- for i in range(len(labels_true)):
- if labels_true[i]==labels_predicted[i]:
- correct+=1
- return int((correct/len(labels_true))*100)
- f1 = sys.argv[1] #Actual File
- f2 = sys.argv[2] #Predictions File
- #f1='./Solution.csv'
- #f2='./Solution.csv'
- print(check(f1,f2))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement