-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrun_f1.py
More file actions
35 lines (28 loc) · 1.38 KB
/
Copy pathrun_f1.py
File metadata and controls
35 lines (28 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
ground_truth_path = '/Users/lucykim/Downloads/midi_files_ground_truth'
prediction_path = '/Users/lucykim/Downloads/midi_files_w_pedal'
import os
import csv
from get_f1 import get_f1, get_f1_naive
prediction_file_set = set()
for root, dirs, files in os.walk(prediction_path):
for file in files:
prediction_file_set.add(file[:-5])
# Assuming a CSV file named 'f1_scores.csv' exists in the current directory
with open('f1_scores.csv', mode='a', newline='') as file:
writer = csv.writer(file)
# Write the header if the file is empty
if file.tell() == 0:
writer.writerow(['File Name', 'Naive F1 Score 69', 'Naive F1 Score 71', 'Naive F1 Score 72', 'Ground F1 Score 69', 'Ground F1 Score 71', 'Ground F1 Score 72'])
for root, dirs, files in os.walk(ground_truth_path):
count = 0
for file in files:
if file[:-5] in prediction_file_set:
ground = ground_truth_path+'/'+file
predicted = prediction_path+'/'+file
naive_f1 = get_f1_naive(ground, predicted)
print('naive:',naive_f1)
ground_f1 = get_f1(ground, predicted)
print('ground:',ground_f1)
count += 1
# Write the scores for the current file
writer.writerow([file, naive_f1[0], naive_f1[1], naive_f1[2], ground_f1[0], ground_f1[1], ground_f1[2]])