film-poster-genres/gnuplot/generate-graph.sh
Starbeamrainbowlabs 60cd7ef5bb
Add gnuplot graphing script
Note to self: This was lifted from our PhD-Code repo
2020-09-18 17:23:51 +01:00

26 lines
705 B
Bash
Executable file

#!/usr/bin/env bash
script_root="$(dirname "$(readlink -f "$0")")";
temp_dir="$(mktemp --tmpdir -d "gnuplot-XXXXXXX")";
on_exit() {
rm -rf "${temp_dir}";
}
trap on_exit EXIT;
graph_data_rmse() {
jq --raw-output "[ input_line_number - 1, (.mse | sqrt), (.val_mse | sqrt) ] | @tsv"
}
metrics_filename="${1}";
if [[ -z "${metrics_filename}" ]]; then
echo "Error: No metrics json file specified.";
exit 1;
fi
tmpfile_metrics="${temp_dir}/data";
graph_data_rmse <"${metrics_filename}" >"${tmpfile_metrics}";
gnuplot -e "metric_name='Root Mean Squared Error'; graph_title='Film Genres Predictor - Root Mean Squared Error'; data_filename='${tmpfile_metrics}'" "${script_root}/tensorflow-metrics.plt"