modeva.TestSuite.interpret_local_linear_fi#
- TestSuite.interpret_local_linear_fi(dataset: str = 'test', sample_index: int = 0, centered: bool = True)#
Calculate and visualize local feature importance for a specific data sample using linear approximation.
This function computes the local feature importance scores for a given sample from the specified dataset using a linear model. It visualizes the importance scores alongside the original feature values and coefficients, providing insights into the contribution of each feature to the model’s prediction.
- Parameters:
dataset ({"main", "train", "test"}, default="test") – Specifies which dataset partition to use for the analysis.
sample_index (int, default=0) – Index of the specific sample in the selected dataset to analyze.
centered (bool, default=True) – If True, features are centered by subtracting their mean values before calculating importance scores.
- Returns:
A container object with the following components:
key: “interpret_local_linear_fi”
data: Name of the dataset used
model: Name of the model used
inputs: Input parameters
value: Dictionary containing:
”Name”: List of feature names
”Importance”: Feature importance scores
”Values”: Original feature values
”Coefficients”: Linear coefficients
table: DataFrame containing feature names, scores, values, and coefficients
options: Dictionary of visualizations configuration for a horizontal bar-stem plot where x-axis is importance, and y-axis is the feature names. Run results.plot() to show this plot.
- Return type:
Examples