explainy.utils package#

Submodules#

explainy.utils.surrogate_plot module#

exception explainy.utils.surrogate_plot.GraphvizNotFoundError[source]#

Bases: Exception

class explainy.utils.surrogate_plot.SurrogatePlot(precision: int = 2, impurity: bool = False, rounded: bool = True, class_names: bool = True)[source]#

Bases: object

This class create the graphviz based surrogate plot using the trained sklearn DecisionTree

get_plot(model: ClassifierMixin | RegressorMixin, feature_names: List[str])[source]#

Update the dot file as desired, simplify the text in the boxes

static one_hot_encoding_text(tree: str) str[source]#

Customize the labels text for one-hot encoded features

explainy.utils.surrogate_text module#

class explainy.utils.surrogate_text.SurrogateText(text: str, model: object, X: array, feature_names: list)[source]#

Bases: object

find_path(node_numb, path, x)[source]#
Parameters:
  • node_numb (TYPE) – DESCRIPTION.

  • path (TYPE) – DESCRIPTION.

  • x (TYPE) – DESCRIPTION.

Returns:

DESCRIPTION.

Return type:

bool

get_paths() dict[source]#
get_rule(path)[source]#
Parameters:

path (TYPE) – DESCRIPTION.

Returns:

DESCRIPTION.

Return type:

TYPE

get_text()[source]#

Returns: TYPE: DESCRIPTION.

explainy.utils.utils module#

exception explainy.utils.utils.NonConvergenceError[source]#

Bases: Exception

Custom exception for non-convergence of the CounterFactual explanation optimization algorithm

explainy.utils.utils.create_folder(path: str) str[source]#

Create folder, if it doesn’t already exist

explainy.utils.utils.get_number_to_string_dict() None[source]#

Map number of features to string values

explainy.utils.utils.join_text_with_comma_and_and(values: list) str[source]#

Merge values for text output with commas and only the last value with an “and””

Parameters:

values (list) – list of values to be merged.

Returns:

new text.

Return type:

str

Module contents#