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
instance
to 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
instance
is not a 1-dimensional numpy array or any ofcounterfactuals
,counterfactuals_distances
orcounterfactuals_predictions
is not a 2-dimensional numpy array.- IndexError
The
counterfactuals
and theinstance
column indices disagree.- TypeError
The
instance_class
parameter is neither an integer nor a string. The types of theinstance
and thecounterfactuals
arrays are different.- ValueError
The
instance
is not of a base type (strings and/or numbers); thecounterfactuals
is not of a base type; thecounterfactuals_distances
is not a purely numerical array; orcounterfactuals_predictions
is not a base array. Either the length of thecounterfactuals_distances
array or of thecounterfactuals_predictions
array is not the same as the number of rows in thecounterfactuals
array. The type of theinstance_class
is different than the type of thecounterfactuals_predictions
array.