nlsq.diagnostics.ParameterSensitivityAnalyzer¶
- class nlsq.diagnostics.ParameterSensitivityAnalyzer(config=None)[source]¶
Bases:
objectAnalyzer for parameter sensitivity spectrum from Jacobian matrices.
This class analyzes the eigenvalue spectrum of the Fisher Information Matrix (FIM) to identify well-determined vs poorly-determined parameter directions. It detects wide eigenvalue spread when eigenvalues span many orders of magnitude.
- Parameters:
config (DiagnosticsConfig | None) – Configuration containing thresholds for sensitivity analysis. If None, uses default configuration.
- config¶
Configuration for the analyzer.
- Type:
Notes
Detection logic:
A model is considered to have wide eigenvalue spread when its eigenvalue range exceeds a threshold derived from the config’s sloppy_threshold.
The sloppy_threshold (default 1e-6) defines when a direction is classified as poorly-determined: eigenvalue < threshold * max_eigenvalue.
The overall is_sloppy flag is set when eigenvalue range (in orders of magnitude) is significant enough to cause practical issues.
Examples
>>> import numpy as np >>> from nlsq.diagnostics import DiagnosticsConfig >>> from nlsq.diagnostics.parameter_sensitivity import ParameterSensitivityAnalyzer >>> config = DiagnosticsConfig() >>> analyzer = ParameterSensitivityAnalyzer(config) >>> J = np.random.randn(100, 3) # 100 data points, 3 parameters >>> report = analyzer.analyze(J) >>> print(report.is_sloppy) False
- DEFAULT_SLOPPY_DETECTION_ORDERS = 2.0¶
- STIFF_RATIO_THRESHOLD = 0.1¶
- SLOPPY_RATIO_THRESHOLD = 0.01¶
- __init__(config=None)[source]¶
Initialize the parameter sensitivity analyzer.
- Parameters:
config (DiagnosticsConfig | None) – Configuration containing analysis thresholds. If None, uses default configuration.
- analyze(jacobian)[source]¶
Analyze parameter sensitivity spectrum from a Jacobian matrix.
Computes the Fisher Information Matrix (FIM) as J.T @ J and analyzes its eigenvalue spectrum for wide eigenvalue spread.
- Parameters:
jacobian (np.ndarray) – Jacobian matrix of shape (n_data, n_params).
- Returns:
Report containing analysis results and any detected issues.
- Return type:
Notes
The analysis includes:
FIM computation: FIM = J.T @ J
Eigenvalue decomposition for spectrum analysis
Eigenvalue range computation (log10 ratio)
Stiff/poorly-determined direction classification
Effective dimensionality using participation ratio
Issue detection based on thresholds