Skip to content

Commit

Permalink
Added creation of json files for each evaluation
Browse files Browse the repository at this point in the history
  • Loading branch information
ecmjohnson committed Aug 4, 2016
1 parent 249aca3 commit 91346fe
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions dsdtools/evaluate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
import numpy as np
import mir_eval
import pandas as pd
import json
from os import path as op


class DF_writer(object):
Expand Down Expand Up @@ -122,6 +124,26 @@ def evaluate_track(
except ValueError:
pass

if estimates_dir and rows:
try:
# save the dataframe corresponding to this estimate as json
temp_frame = pd.DataFrame()
for row in rows:
temp_frame = temp_frame.append(row, ignore_index=True)
json_string = json.dumps(json.loads(temp_frame.to_json()),
sort_keys=True,
indent=4,
separators=(',',':'))
track_dir = op.join(
estimates_dir,
track.subset,
track.filename
)
with open(track_dir + '/evaluation.json', 'w') as f:
f.write(json_string)
except ValueError, IOError:
pass

return rows

def evaluate(self, estimates, references):
Expand Down

0 comments on commit 91346fe

Please sign in to comment.