stanza.analysis.criterion
Fit quality assessment criteria for curve fitting.
This module provides functions to evaluate the quality of nonlinear curve fits using statistically robust metrics like R² and NRMSE.
Module Contents
Functions
API
Evaluate fit quality using R² and NRMSE metrics.
This criterion evaluates both how well the model explains variance (R²) and how small the errors are relative to the data range (NRMSE).
Parameters:
x_data
Input x values (used for context, not in calculation)
y_data
Observed y values
y_pred
Predicted y values from the fitted model
r_squared_threshold
Minimum R² value for acceptable fit. Default 0.7
nrmse_threshold
Maximum NRMSE (normalized RMSE) for acceptable fit.
Returns:
True if fit quality is GOOD (passes both criteria), False if POOR Notes:
- R² (coefficient of determination) measures the proportion of variance in the data explained by the model. Range: [0, 1], higher is better.
- NRMSE (normalized root mean square error) measures prediction error relative to data range. Range: [0, ∞), lower is better.
- These metrics are appropriate for nonlinear models, unlike reduced chi-squared which requires known degrees of freedom.

