wildboar.explain.counterfactual._helper#
Module Contents#
Functions#
|
Compute a single counterfactual example for each sample |
- wildboar.explain.counterfactual._helper.counterfactuals(estimator, x, y, *, train_x=None, train_y=None, method='best', scoring='deprecated', valid_scoring='deprecated', proximity=None, random_state=None, method_args=None)[source]#
Compute a single counterfactual example for each sample
- Parameters:
estimator (object) – The estimator used to compute the counterfactual example
x (array-like of shape (n_samples, n_timestep)) – The data samples to fit counterfactuals to
y (array-like broadcast to shape (n_samples,)) – The desired label of the counterfactual
method (str or BaseCounterfactual, optional) –
The method to generate counterfactual explanations
if ‘best’, infer the most appropriate counterfactual explanation method based on the estimator
Changed in version 1.1.0.
if str, select counterfactual explainer from named collection. See
_COUNTERFACTUALS.keys()for a list of valid values.if, BaseCounterfactual use the supplied counterfactual
scoring (str, callable, list or dict, optional) –
The scoring function to determine the similarity between the counterfactual sample and the original sample
Deprecated since version 1.1:
scoringwas renamed toproximityin 1.1 and will be removed in 1.2.proximity (str, callable, list or dict, optional) – The scoring function to determine the similarity between the counterfactual sample and the original sample
valid_scoring (bool, optional) –
Only compute score for successful counterfactuals.
Deprecated since version 1.1:
valid_scoringwill be removed in 1.2.random_state (RandomState or int, optional) – The pseudo random number generator to ensure stable result
method_args (dict, optional) –
Optional arguments to the counterfactual explainer.
New in version 1.1.0.
- Returns:
x_counterfactuals (ndarray of shape (n_samples, n_timestep)) – The counterfactual example.
valid (ndarray of shape (n_samples,)) – Indicator matrix for valid counterfactuals
score (ndarray of shape (n_samples,) or dict, optional) – Return score of the counterfactual transform, if
scoringis not None