evaluate
Metrics and evaluations?
- pynumdiff.utils.evaluate.error_correlation(dxdt_hat, dxdt_truth, padding=None)
Calculate the error correlation (pearsons correlation coefficient) between the estimated dxdt and true dxdt
- Parameters
dxdt_hat (np.array) – estimated xdot
dxdt_truth (np.array like x or None) – true value of dxdt, if known, optional
padding (int, None, or auto) – number of snapshots on either side of the array to ignore when calculating the metric. If autor or None, defaults to 2.5% of the size of x
- Returns
r-squared correlation coefficient
- Return type
float
- pynumdiff.utils.evaluate.metrics(x, dt, x_hat, dxdt_hat, x_truth=None, dxdt_truth=None, padding=None)
Evaluate x_hat based on various metrics, depending on whether dxdt_truth and x_truth are known or not.
- Parameters
x (np.array) – time series that was differentiated
dt (float) – time step in seconds
x_hat (np.array) – estimated (smoothed) x
dxdt_hat (np.array) – estimated xdot
x_truth (np.array like x or None) – true value of x, if known, optional
dxdt_truth (np.array like x or None) – true value of dxdt, if known, optional
padding (int, None, or auto) – number of snapshots on either side of the array to ignore when calculating the metric. If autor or None, defaults to 2.5% of the size of x
- Returns
a tuple containing the following: - rms_rec_x: RMS error between the integral of dxdt_hat and x - rms_x: RMS error between x_hat and x_truth, returns None if x_truth is None - rms_dxdt: RMS error between dxdt_hat and dxdt_truth, returns None if dxdt_hat is None
- Return type
tuple -> (float, float, float)
- pynumdiff.utils.evaluate.plot(x, dt, x_hat, dxdt_hat, x_truth, dxdt_truth, xlim=None, ax_x=None, ax_dxdt=None, show_error=True, markersize=5)
Make comparison plots of ‘x (blue) vs x_truth (black) vs x_hat (red)’ and ‘dxdt_truth (black) vs dxdt_hat (red)’
- Parameters
x (np.array (float)) – array of noisy time series
dt (float) – a float number representing the time step size
x_hat (np.array (float)) – array of smoothed estimation of x
dxdt_hat (np.array (float)) – array of estimated derivative
x_truth (np.array (float)) – array of noise-free time series
dxdt_truth (np.array (float)) – array of true derivative
xlim (list (2 integers), optional) – a list specifying range of x
ax_x (
matplotlib.axes, optional) – axis of the first plotax_dxdt (
matplotlib.axes, optional) – axis of the second plotshow_error (boolean, optional) – whether to show the rmse
markersize (int, optional) – marker size of noisy observations
- Returns
Display two plots
- Return type
None
- pynumdiff.utils.evaluate.rmse(dxdt_hat, dxdt_truth, padding=None)
Calculate the Root Mean Squared Error between the estimated dxdt and true dxdt
- Parameters
dxdt_hat (np.array) – estimated xdot
dxdt_truth (np.array like x or None) – true value of dxdt, if known, optional
padding (int, None, or auto) – number of snapshots on either side of the array to ignore when calculating the metric. If autor or None, defaults to 2.5% of the size of x
- Returns
Root Mean Squared Error
- Return type
float