PartialDependence
Global explainer that shows how the model's average prediction changes with each feature.
A Partial Dependence Plot (PDP) marginalises the model output over the
distribution of all other features, leaving a curve (or surface) that
shows the average effect of the target feature in isolation. For a feature
x_j, the partial dependence is:
::
f̄(x_j) = E_(x_-j) [ f(x_j, x_-j) ] ≈ (1/n) Σ_i f(x_j, x_-j,i)
PDPs assume feature independence; when features are correlated, the marginalisation extrapolates into regions with low data density. Individual Conditional Expectation (ICE) plots (one line per sample) can be overlaid to detect heterogeneous effects hidden by the average.
References
- [1] Friedman, J.H. (2001). "Greedy function approximation: A gradient boosting machine." Annals of Statistics, 29(5), 1189-1232.
- [2] https://scikit-learn.org/stable/modules/partial_dependence.html
Parameters
- grid_resolution : integer, default=
100 - Number of equidistant points to split the range of the target feature.
- lower_percentile : number, default=
0.05 - Lower percentile used to limit the feature values.
- upper_percentile : number, default=
0.95 - Upper percentile used to limit the feature values.
Methods
explain(self, dataset)
PartialDependenceMethod to generate the explanation
Parameters
- X: Tuple[DatasetDict, DatasetDict]
- Tuple with (input_samples, targets). Input samples are used to evaluate the partial dependence of each feature
- Returns:
- dict
- Dictionary with metadata and the partial dependence of each feature
plot(self, explanation: dict) -> List[dict]
PartialDependenceMethod to create the explanation plot.
Parameters
- explanation: dict
- dictionary with the explanation generated by the explainer.
- Returns:
- List[dict]
- list of JSONs containing the information of the explanation plot to be rendered.
get_schema(cls) -> dict
ConfigObjectGenerates the component related Json Schema.
Returns
- dict
- Dictionary representing the Json Schema of the component.
validate_and_transform(self, raw_data: dict) -> dict
ConfigObjectIt takes the data given by the user to initialize the model and returns it with all the objects that the model needs to work.
Parameters
- raw_data : dict
- A dictionary with the data provided by the user to initialize the model.
Returns
- dict
- A validated dictionary with the necessary objects.