fatf.transparency.predictions.counterfactuals.textualise_counterfactuals(instance, counterfactuals, instance_class=None, counterfactuals_distances=None, counterfactuals_predictions=None)[source]

Translates a counterfactuals array into a textual description.

instancenumpy.ndarray or numpy.void

A 1-dimensional numpy array representing a data point for which counterfactuals were calculated.


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.


A string representation of the counterfactuals.


instance is not a 1-dimensional numpy array or any of counterfactuals, counterfactuals_distances or counterfactuals_predictions is not a 2-dimensional numpy array.


The counterfactuals and the instance column indices disagree.


The instance_class parameter is neither an integer nor a string. The types of the instance and the counterfactuals arrays are different.


The instance is not of a base type (strings and/or numbers); the counterfactuals is not of a base type; the counterfactuals_distances is not a purely numerical array; or counterfactuals_predictions is not a base array. Either the length of the counterfactuals_distances array or of the counterfactuals_predictions array is not the same as the number of rows in the counterfactuals array. The type of the instance_class is different than the type of the counterfactuals_predictions array.

Examples using fatf.transparency.predictions.counterfactuals.textualise_counterfactuals