fatf.transparency.predictions.counterfactuals.textualise_counterfactuals¶
-
fatf.transparency.predictions.counterfactuals.textualise_counterfactuals(instance: Union[numpy.ndarray, numpy.void], counterfactuals: numpy.ndarray, instance_class: Union[int, str, None] = None, counterfactuals_distances: Optional[numpy.ndarray] = None, counterfactuals_predictions: Optional[numpy.ndarray] = None) → str[source]¶ Translates a counterfactuals array into a textual description.
- Parameters
- instancenumpy.ndarray or numpy.void
A 1-dimensional numpy array representing a data point for which counterfactuals were calculated.
- counterfactualsnumpy.ndarray
A 2-dimensional numpy array with the counterfactual data points.
- instance_classstring or integer, optional (default=None)
The class of the input
instance.- counterfactuals_distancesnumpy.ndarray, optional (default=None)
A 1-dimensional numpy array with distances from the input
instanceto every counterfactual data point.- counterfactuals_predictionsnumpy.ndarray, optional (default=None)
A 1-dimensional numpy array with predictions for every counterfactual data point.
- Returns
- textualisationstring
A string representation of the
counterfactuals.
- Raises
- IncorrectShapeError
instanceis not a 1-dimensional numpy array or any ofcounterfactuals,counterfactuals_distancesorcounterfactuals_predictionsis not a 2-dimensional numpy array.- IndexError
The
counterfactualsand theinstancecolumn indices disagree.- TypeError
The
instance_classparameter is neither an integer nor a string. The types of theinstanceand thecounterfactualsarrays are different.- ValueError
The
instanceis not of a base type (strings and/or numbers); thecounterfactualsis not of a base type; thecounterfactuals_distancesis not a purely numerical array; orcounterfactuals_predictionsis not a base array. Either the length of thecounterfactuals_distancesarray or of thecounterfactuals_predictionsarray is not the same as the number of rows in thecounterfactualsarray. The type of theinstance_classis different than the type of thecounterfactuals_predictionsarray.