Generate Explanations
In this section, we show you how to create explanations using the Python Client
Details about how to plot and store the explanations that will be presented in this section, can be found here:
expai.ExpaiModelExplainer
expai.ExpaiModelExplainer
To initialise this class, it is required to get a ModelFairness object using expai.ExpaiProject.get_model_explainer()
. More info here.
expai.ExpaiModelExplainer.get_allowed_explanations
expai.ExpaiModelExplainer.get_allowed_explanations
This method returns a ExpaiModelExplainer that enables easy explanation generation.
expai.ExpaiProject.get_allowed_explanations(self)
All following methods will return an ExpaiExplanation object containing the plots used to represent the explanation. See more information here.
expai.ExpaiModelExplainer.explain_model
expai.ExpaiModelExplainer.explain_model
Explain a model based on a whole dataset or a subset representing some meaningful group for your operations.
expai.ExpaiModelExplainer.explain_model(self, sample_name: str = None, sample_id: str = None, subset_indexes: list = None, target_class: str = None)
subset_indexes
allow you to explain your model based only on a meaningful subgroup in your data. You can use expai.ExpaiProject.get_sample()
to obtain a dataframe, filter and then use the desired indexes.
expai.ExpaiModelExplainer.explain_variable_effect
expai.ExpaiModelExplainer.explain_variable_effect
Explain how a single variable impacts the predictions in your model.
expai.ExpaiModelExplainer.explain_variable_effect(self, sample_name: str = None, sample_id: str = None, subset_indexes: list = None, target_class: str = None, variables: list = None, variables_type: dict = None)
subset_indexes
allow you to explain your model based only on a meaningful subgroup in your data. You can use expai.ExpaiProject.get_sample()
to obtain a dataframe, filter and then use the desired indexes.
expai.ExpaiModelExplainer.explain_sample
expai.ExpaiModelExplainer.explain_sample
Explain how the prediction for a certain sample was made and the importance of each variable.
expai.ExpaiModelExplainer.explain_sample(self, sample_name: str = None, sample_id: str = None, index: int = None, subset_indexes: list = None, target_class: str = None)
If you use subset_indexes,
make sure they contain the index you want to explain.
WHAT IF
This module allows you to validate and activate business actions based on your analytical models on the fly.
expai.ExpaiModelExplainer.what_if
expai.ExpaiModelExplainer.what_if
Explain how a variable will change the prediction for a single entry when it takes any of its possible values. Obtain a plot for each variable representing the prediction for each possible value when all remaining variables are kept the same.
expai.ExpaiModelExplainer.what_if(self, sample_name: str = None, sample_id: str = None, index: int = None, subset_indexes: list = None, target_class: str = None, variables: list = None, variables_type: dict = None)
subset_indexes
allow you to explain your model based only on a meaningful subgroup in your data. You can use expai.ExpaiProject.get_sample()
to obtain a dataframe, filter and then use the desired indexes.
expai.ExpaiModelExplainer.what_if_battle
expai.ExpaiModelExplainer.what_if_battle
With this explanation, you will be able to change the values you want for a single entry and obtain the new prediction and its explanation after the changes. Validate business decisions on the fly.
expai.ExpaiModelExplainer.what_if_battle(self, sample_name: str = None, sample_id: str = None, index: int = None, subset_indexes: list = None, target_class: str = None, replace_dict: dict = None, display_replace_dict: dict = None)
subset_indexes
allow you to explain your model based only on a meaningful subgroup in your data. You can use expai.ExpaiProject.get_sample()
to obtain a dataframe, filter and then use the desired indexes.
Last updated