trustyai.explainers.CounterfactualResult
- class trustyai.explainers.CounterfactualResult(result: CounterfactualResult)
Wraps Counterfactual results. This object is returned by the
CounterfactualExplainer, and provides a variety of methods to visualize and interact with the results of the counterfactual explanation.- __init__(result: CounterfactualResult) None
Constructor method. This is called internally, and shouldn’t ever need to be used manually.
Methods
__init__(result)Constructor method.
Return the counterfactual result as a dataframe
as_html()Return the counterfactual result as a Pandas Styler object.
plot([block, call_show])Plot the counterfactual result.
Attributes
Return the proposed feature values found from the counterfactual explanation as a Numpy array.
Return the proposed feature values found from the counterfactual explanation as a Pandas DataFrame.
- as_dataframe() DataFrame
Return the counterfactual result as a dataframe
- Returns:
- pandas.DataFrame
DataFrame containing the results of the counterfactual explanation, containing the following columns:
Features: The names of each input feature.Proposed: The found values of the features.Original: The original feature values.Constrained: Whether this feature was constrained (held fixed) during the search.Difference: The difference between the proposed and original values.
- as_html() Styler
Return the counterfactual result as a Pandas Styler object.
- Returns:
- pandas.Styler
Styler containing the results of the counterfactual explanation, in the same schema as in
as_dataframe(). Currently, no default styles are applied in this particular function, making it equivalent toself.as_dataframe().style.
- plot(block=True, call_show=True) None
Plot the counterfactual result.
- property proposed_features_array
Return the proposed feature values found from the counterfactual explanation as a Numpy array.
- property proposed_features_dataframe
Return the proposed feature values found from the counterfactual explanation as a Pandas DataFrame.