modeva.TestSuite.interpret_effects#
- TestSuite.interpret_effects(features: str | Tuple = None, dataset: str = 'test', grid_size: int = 200)#
Analyze and visualize how one or two features influence model predictions through main effects or interaction effects.
This method computes and visualizes how specified features affect the model’s output, allowing for both single and dual feature analysis. It generates visualizations such as line plots, bar plots, or heatmaps based on the type of features provided, and returns a structured result encapsulating the effects and visual options.
- Parameters:
features (str or tuple of str) –
Name of single feature or tuple of two feature names to analyze their effects on model output.
If features=(“X1”, ) or “X1”, visualize the main effect for X1.
If features=(“X1”, “X2”), visualize the interaction for X1 and X2.
If features=((“X1”, ), (“X2”, )), visualize the main effect for X1 and X2 separately.
Note: Batch mode for 2D effect plot is not supported. If None, all 1D features will be used.
dataset ({"main", "train", "test"}, default="test") – Dataset partition to use for effect calculations. Controls which data points are used to determine the range and importance of effects.
grid_size (int, default=200) – Resolution of the effect visualization grid. Higher values create smoother visualizations but increase computation time.
- Returns:
A container object with the following components:
key: “interpret_effect”
data: Name of the dataset used
model: Name of the model used
inputs: Input parameters
value: Dictionary containing:
”Value”: Feature values used for effect calculation
”Effect”: Calculated effect values
”Details”: A dict containing details about the effects
table: DataFrame containing the effect results
For single feature: columns are “Value” and “Effect”
For two features: 2D table with features as row/column indices
options: Dictionary of visualizations configuration for a line (1D numerical) / bar (1D categorical) / heatmap (2D) effect plot. Run results.plot() to show all plots; To display one preferred plot by results.plot(name=xxx), and the following names are available:
None: Effect plots of all effects specified in features.
”<effect_name>”: Effect plot of the selected main effect or pairwise interaction.
- Return type:
Examples