Post-hoc sensitivity¶
sensitivity_from_table() fits a surrogate over completed experiments and
estimates Morris or Sobol sensitivity cheaply through that model. Inspect its
cross-validated accuracy before interpreting importance: this measures the
surrogate's estimated response, not a new set of simulator evaluations.
Use sobol_indices() when you need first-order and total-order indices together;
ST - S1 reveals effects attributable to interactions.
trade_study.TableSensitivity(importance, surrogate_cv_r2)
dataclass
¶
Post-hoc sensitivity indices computed via a table-fit surrogate.
Attributes:
| Name | Type | Description |
|---|---|---|
importance |
dict[str, NDArray[floating[Any]]]
|
Mapping from observable name to an array of factor
importances (mu_star for Morris, S1 for Sobol), one value per
continuous factor, in the same order as
:func: |
surrogate_cv_r2 |
dict[str, float]
|
Per-observable cross-validated R^2 of the surrogate the indices were computed from (#114). A low value means the sensitivity indices reflect a poorly learned response surface, not necessarily the true system -- treat such observables' indices as unreliable. |
trade_study.sensitivity_from_table(results, factors, *, method='sobol', surrogate_method='rf', n_trajectories=100, seed=42, n_estimators=200, warn_below_r2=0.0)
¶
Compute post-hoc Sobol/Morris sensitivity from a collected table.
Only continuous factors are screened, matching screen()'s own
contract; the surrogate is fit on that same continuous subset, so any
non-continuous keys present in results.configs (categorical
factors, bookkeeping fields, etc.) are simply ignored rather than
causing an encoding mismatch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
results
|
ResultsTable
|
A :class: |
required |
factors
|
list[Factor]
|
Factor definitions to screen. Non-continuous factors are
dropped (as in |
required |
method
|
str
|
|
'sobol'
|
surrogate_method
|
str
|
|
'rf'
|
n_trajectories
|
int
|
Forwarded to |
100
|
seed
|
int
|
Random seed for both the surrogate fit and |
42
|
n_estimators
|
int
|
Forwarded to :func: |
200
|
warn_below_r2
|
float | None
|
Forwarded to :func: |
0.0
|
Returns:
| Name | Type | Description |
|---|---|---|
A |
TableSensitivity
|
class: |
TableSensitivity
|
surrogate's cross-validated accuracy per observable. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |