contango.trading.analysis.graphing.parameter_importance
contango.trading.analysis.graphing.parameter_importance
ParameterImportance
ParameterImportance(config: C)
Bases: GraphType[ParameterImportanceConfig]
A graph type that shows the sensitivity of a metric to each swept parameter.
Source code in src\contango\trading\analysis\graph_type.py
26 27 28 29 30 31 32 33 | |
build
build(df: DataFrame) -> go.Figure
Builds the parameter importance bar chart.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
The tidy experiment DataFrame. |
required |
Returns:
| Type | Description |
|---|---|
Figure
|
A plotly Figure. |
Source code in src\contango\trading\analysis\graphing\parameter_importance.py
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 | |
ParameterImportanceConfig
dataclass
ParameterImportanceConfig(param_columns: list[str], target_metric: str = 'calmar_ratio')
Bases: GraphConfig
A graph configuration specific to the parameter importance graph.
Attributes:
| Name | Type | Description |
|---|---|---|
param_columns |
list[str]
|
The parameter columns to score. |
target_metric |
str
|
The name for the targeted metric to explain. |
compute_parameter_importance
compute_parameter_importance(df: DataFrame, target_metric: str, param_columns: list[str]) -> pd.DataFrame
Scores each parameter's importance to target_metric using an eta-squared measure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
Experiment DataFrame. |
required |
target_metric
|
str
|
The metric column to explain (e.g. "calmar_ratio"). |
required |
param_columns
|
list[str]
|
Parameter columns to score. |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
DataFrame with columns ["parameter", "importance"], sorted descending. |
Source code in src\contango\trading\analysis\graphing\parameter_importance.py
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 | |