Skip to content

Commit

Permalink
report nrmse etc.
Browse files Browse the repository at this point in the history
  • Loading branch information
fhchl committed Aug 10, 2023
1 parent e9693fc commit 359906c
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 15 deletions.
11 changes: 9 additions & 2 deletions dynax/estimation.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

from .evolution import AbstractEvolution
from .system import DynamicalSystem
from .util import value_and_jacfwd
from .util import mse, nmse, nrmse, value_and_jacfwd


def _get_bounds(module: eqx.Module) -> tuple[list, list]:
Expand Down Expand Up @@ -209,9 +209,16 @@ def residuals(params):
)

# Unscale mse to Least-Squares cost.
res.jac = res.jac * np.sqrt(res_size / 2) # TODO: check this
res.fun = res.fun[: y.size].reshape(y.shape) / np.sqrt(2 / res_size) / weight
res.jac = res.jac * np.sqrt(res_size / 2)
res.cost = res.cost * res_size / 2

# Compute normalized root-mean-squared error
y_pred = y - res.fun
res.mse = np.atleast_1d(mse(y, y_pred))
res.nmse = np.atleast_1d(nmse(y, y_pred))
res.nrmse = np.atleast_1d(nrmse(y, y_pred))

# Compute covariance matrix.
# pcov = H^{-1} ~= inv(J^T J). Use regularized inverse.
_, s, VT = svd(res.jac, full_matrices=False)
Expand Down
Loading

0 comments on commit 359906c

Please sign in to comment.