nlsq.diagnostics.DiagnosticsConfig

class nlsq.diagnostics.DiagnosticsConfig(level=DiagnosticLevel.BASIC, condition_threshold=100000000.0, correlation_threshold=0.95, imbalance_threshold=1000000.0, vanishing_threshold=1e-06, sloppy_threshold=1e-06, gradient_window_size=100, stagnation_window=10, stagnation_tolerance=0.01, verbose=True, emit_warnings=True)[source]

Bases: object

Configuration for diagnostic computation.

This frozen dataclass contains all thresholds and settings used by the diagnostic analyzers. Being frozen ensures configuration immutability during analysis.

level

Diagnostic analysis depth.

Type:

DiagnosticLevel

condition_threshold

FIM condition number threshold for practical identifiability. Default: 1e8.

Type:

float

correlation_threshold

Correlation coefficient threshold for high correlation warning. Default: 0.95.

Type:

float

imbalance_threshold

Gradient imbalance ratio threshold. Default: 1e6.

Type:

float

vanishing_threshold

Relative gradient magnitude threshold for vanishing detection. Default: 1e-6.

Type:

float

sloppy_threshold

Eigenvalue ratio threshold for sensitivity classification. Default: 1e-6.

Type:

float

gradient_window_size

Window size for gradient norm history. Default: 100.

Type:

int

stagnation_window

Number of iterations to check for gradient stagnation. Default: 10.

Type:

int

stagnation_tolerance

Relative tolerance for detecting gradient stagnation. Default: 0.01 (1% change).

Type:

float

verbose

Print diagnostic summary to console. Default: True.

Type:

bool

emit_warnings

Emit Python warnings for critical issues. Default: True.

Type:

bool

Examples

>>> config = DiagnosticsConfig()
>>> config.level
<DiagnosticLevel.BASIC: 1>
>>> config.condition_threshold
100000000.0
>>> config = DiagnosticsConfig(
...     level=DiagnosticLevel.FULL,
...     condition_threshold=1e10,
...     verbose=False,
... )
>>> config.level
<DiagnosticLevel.FULL: 2>
level: DiagnosticLevel
condition_threshold: float
correlation_threshold: float
imbalance_threshold: float
vanishing_threshold: float
sloppy_threshold: float
gradient_window_size: int
stagnation_window: int
stagnation_tolerance: float
verbose: bool
emit_warnings: bool
__post_init__()[source]

Validate configuration values after initialization.

__init__(level=DiagnosticLevel.BASIC, condition_threshold=100000000.0, correlation_threshold=0.95, imbalance_threshold=1000000.0, vanishing_threshold=1e-06, sloppy_threshold=1e-06, gradient_window_size=100, stagnation_window=10, stagnation_tolerance=0.01, verbose=True, emit_warnings=True)