ICE
- class ordinal_xai.interpretation.ice.ICE(model, X, y=None)[source]
Bases:
BaseInterpretationIndividual Conditional Expectation (ICE) Plot interpretation method.
ICE plots show how a model’s prediction changes as a feature value changes, while keeping other features constant. For ordinal regression, it shows how the probability distribution across ordinal classes changes with feature variations.
- Parameters:
model (object) – The trained ordinal regression model. Must implement predict_proba method.
X (pd.DataFrame) – Dataset used for interpretation. Should contain the same features used during model training.
y (pd.Series, optional) – Target labels. Not required for interpretation but useful for reference.
- model
The trained ordinal regression model
- Type:
object
- X
Dataset used for interpretation
- Type:
pd.DataFrame
- y
Target labels (if provided)
- Type:
pd.Series
- __init__(model, X, y=None)[source]
Initialize the ICE Plot interpretation method.
- Parameters:
model (object) – The trained ordinal regression model
X (pd.DataFrame) – Dataset used for interpretation
y (pd.Series, optional) – Target labels
- explain(observation_idx=None, feature_subset=None, plot=False)[source]
Generate Individual Conditional Expectation Plots.
This method computes and optionally visualizes how the model’s predictions change as feature values change. For ordinal regression, it shows how the probability distribution across classes changes with feature variations.
- Parameters:
observation_idx (int, optional) – Index of specific instance to highlight in the plot. If provided, only this instance’s ICE curves will be shown along with the average (PDP).
feature_subset (list, optional) – List of feature names or indices to plot. If None, all features are used.
plot (bool, default=False) – Whether to create visualizations of the ICE plots.
- Returns:
Dictionary containing ICE results for each feature: - ‘grid_values’: Feature values used for prediction - ‘average’: Average predictions (PDP) for each class - ‘individual’: Individual predictions for each instance and class
- Return type:
dict
Notes
For ordinal regression, the plots show probability changes for each class
The average curve (PDP) shows the overall effect of the feature
Individual curves show instance-specific effects
For categorical features, exact feature values are used
For numerical features, a grid of values is used
- _abc_impl = <_abc._abc_data object>