From 757489abd6ef13a6c3549ee9854a476834b5165d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tobias=20M=C3=BCller?= Date: Wed, 27 Mar 2024 12:16:16 -0700 Subject: [PATCH] feat: additional statistical parameters (#109) * added version tag to distinguish test and prod deploy updates * fixed pdf display * removed debug tag, removed outdated todo comments * fixed header size * fix pandas slice warning * added calculation of mean average percentage error, fixed stats update calc * added mape to pdf export --- frontend/rctool/functions/fit_linear_model.py | 8 +- .../templates/rctool/components/navbar.html | 6 +- .../rctool/develop/develop_table_rating.html | 6 ++ .../rctool/develop/rctool_develop_js.html | 81 ++++++++++++------- .../rctool/export/rctool_export_pdf.html | 3 + frontend/rctool/views.py | 12 +-- 6 files changed, 76 insertions(+), 40 deletions(-) diff --git a/frontend/rctool/functions/fit_linear_model.py b/frontend/rctool/functions/fit_linear_model.py index ad13185b..90677d10 100644 --- a/frontend/rctool/functions/fit_linear_model.py +++ b/frontend/rctool/functions/fit_linear_model.py @@ -1,7 +1,7 @@ import pandas as pd import numpy as np from lmfit import models, Parameters -from sklearn.metrics import mean_squared_error +from sklearn.metrics import mean_squared_error, mean_absolute_percentage_error import math @@ -71,9 +71,11 @@ def fit_linear_model(df, offset, label, weighted=None, intersect_points=None, *a # calculate statistical parameters to analyze goodness of fit unw_mse = mean_squared_error(df_data["Q"], unw_best) unw_rmse = math.sqrt(unw_mse) + unw_mape = mean_absolute_percentage_error(df_data["Q"], unw_best) * 100.0 wgt_mse = mean_squared_error(df_data["Q"], wgt_best) wgt_rmse = math.sqrt(wgt_mse) + wgt_mape = mean_absolute_percentage_error(df_data["Q"], wgt_best) * 100.0 # Process and ship output mdl_param = { @@ -84,6 +86,7 @@ def fit_linear_model(df, offset, label, weighted=None, intersect_points=None, *a "seg_bounds": unw_seg_nodes, "offset": offset, "rmse": unw_rmse, + "mape": unw_mape, }, "wgt": { "label": label, @@ -92,6 +95,7 @@ def fit_linear_model(df, offset, label, weighted=None, intersect_points=None, *a "seg_bounds": wgt_seg_nodes, "offset": offset, "rmse": wgt_rmse, + "mape": wgt_mape, }, } @@ -103,6 +107,7 @@ def fit_linear_model(df, offset, label, weighted=None, intersect_points=None, *a "seg_bounds": wgt_seg_nodes, "offset": offset, "rmse": wgt_rmse, + "mape": wgt_mape, } wgt_data = [ [a, b, c] for a, b, c in zip(df_data["H"].tolist(), wgt_best, wgt_residual) @@ -117,6 +122,7 @@ def fit_linear_model(df, offset, label, weighted=None, intersect_points=None, *a "seg_bounds": unw_seg_nodes, "offset": offset, "rmse": unw_rmse, + "mape": unw_mape, } unw_data = [ [a, b, c] for a, b, c in zip(df_data["H"].tolist(), unw_best, unw_residual) diff --git a/frontend/rctool/templates/rctool/components/navbar.html b/frontend/rctool/templates/rctool/components/navbar.html index 1e9c776e..f68820d6 100644 --- a/frontend/rctool/templates/rctool/components/navbar.html +++ b/frontend/rctool/templates/rctool/components/navbar.html @@ -4,11 +4,11 @@
-

HydRA -

+