SFI.utils.formatting module¶
Pretty-printing utilities for inferred models.
- SFI.utils.formatting.model_summary(labels, coefficients, *, stderr=None, support=None, coeffs_true=None, support_true=None, title='Coefficient Table', max_rows=60, significance_thresholds=(2.0, 10.0, 100.0), auto_labels=False)[source]¶
Build a human-readable coefficient table with SNR and significance.
Only active (support) coefficients are shown in the table body. Zeroed basis functions are listed separately below, unless labels are auto-generated.
- Parameters:
labels (sequence of str) – One label per basis function.
coefficients (1-D array) – Coefficient vector (length must match labels or support).
stderr (1-D array or None) – Standard errors (same length as coefficients). These reflect sampling error only; discretization (finite-time-step) bias is not included.
support (1-D int array or None) – Indices into labels that coefficients correspond to. If
None, full support is assumed (all basis functions have non-zero coefficients).title (str) – Section header printed above the table.
max_rows (int) – If the table exceeds this many rows, truncate the middle.
significance_thresholds (tuple of float) – Three SNR thresholds (in multiples of stderr) for the
*,**, and***significance levels. Defaults(2.0, 10.0, 100.0).auto_labels (bool) – If
True, labels were auto-generated (e.g.b0,b1, …) and the list of zeroed functions is suppressed.coeffs_true (ndarray | None)
support_true (ndarray | None)
- Returns:
Ready-to-print multi-line table. Terms are marked , *, or * according to *significance_thresholds*; * terms are bold, * and ** terms are normal weight, non-significant active terms are dimmed.
- Return type:
str
- SFI.utils.formatting.print_model_comparison(inferences, labels, *, extra_cols=None, metrics=None, title='Model Comparison')[source]¶
Build a multi-model comparison table from several inference objects.
- Parameters:
inferences – Sequence of fitted inference objects.
labels – One name per inference (row labels).
metrics – Attribute names to read from each inference (default
["n_params", "NMSE_force", "force_predicted_MSE"]). The special"n_params"countsforce_coefficients_full.extra_cols – Optional
{column_name: {label: value}}of caller-supplied cells.title (str) – Header line.
- Returns:
Ready-to-print table.
- Return type:
str