From 61d52929e55c55265711c3916b25f540eab62c22 Mon Sep 17 00:00:00 2001 From: "Matthew D. Scholefield" Date: Thu, 21 Mar 2019 17:45:09 -0500 Subject: [PATCH] Make precise-eval use new stats object Fixes import error --- precise/scripts/eval.py | 17 ++++++++++++----- runner/precise_runner/util.py | 0 2 files changed, 12 insertions(+), 5 deletions(-) create mode 100644 runner/precise_runner/util.py diff --git a/precise/scripts/eval.py b/precise/scripts/eval.py index 8e6ca05..ae79c0f 100755 --- a/precise/scripts/eval.py +++ b/precise/scripts/eval.py @@ -20,15 +20,18 @@ from precise.network_runner import Listener from precise.params import inject_params from precise.pocketsphinx.listener import PocketsphinxListener from precise.pocketsphinx.scripts.test import test_pocketsphinx -from precise.scripts.test import show_stats, calc_stats, stats_to_dict +from precise.stats import Stats from precise.train_data import TrainData usage = ''' Evaluate a list of models on a dataset - :-t --use-train + :-u --use-train Evaluate training data instead of test data + :-t --threshold floaat 0.5 + Network output to be considered an activation + :-pw --pocketsphinx-wake-word str - Optional wake word used to generate a Pocketsphinx data point @@ -90,11 +93,15 @@ def main(): train, test = data.load(args.use_train, not args.use_train) inputs, targets = train if args.use_train else test predictions = Listener.find_runner(model_name)(model_name).predict(inputs) - stats = calc_stats(sum(data_files, []), targets, predictions) + + stats = Stats(predictions, targets, sum(data_files, [])) print('----', model_name, '----') - show_stats(stats, False) - metrics[model_name] = stats_to_dict(stats) + print(stats.counts_str()) + print() + print(stats.summary_str()) + print() + metrics[model_name] = stats.to_dict(args.threshold) print('Writing to:', args.output) with open(args.output, 'w') as f: diff --git a/runner/precise_runner/util.py b/runner/precise_runner/util.py new file mode 100644 index 0000000..e69de29