explainy.utils package

Submodules

explainy.utils.category_mapper module

Created on Mon Apr 19 19:39:26 2021

@author: maurol

class explainy.utils.category_mapper.CategoryMapper(path, feature)[source]

Bases: object

map the integer of the categorical variables back to the orginal string using the saved json file

get_map_index_dict()[source]

create the dictionary containing the index as key and the string as value

Returns

None.

static key_to_int(mapper)[source]

convert the key of the json file to an integer

Parameters

mapper (TYPE) – DESCRIPTION.

Returns

DESCRIPTION.

Return type

dict

load_json()[source]

load the json file by path

Returns

DESCRIPTION.

Return type

mapper (TYPE)

explainy.utils.surrogate_plot module

Created on Sat Dec 19 12:15:31 2020

@author: mauro

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

Bases: object

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

get_plot(model, feature_names)[source]

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

Parameters
  • model (TYPE) – DESCRIPTION.

  • feature_names (TYPE) – DESCRIPTION.

Returns

DESCRIPTION.

Return type

f (TYPE)

static one_hot_encoding_text(f)[source]

customize the labels text for one-hot encoded features

Parameters

f (TYPE) – DESCRIPTION.

Returns

DESCRIPTION.

Return type

f (TYPE)

explainy.utils.surrogate_text module

Created on Sat Dec 19 11:41:28 2020

@author: mauro

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

Bases: explainy.core.explanation_mixin.ExplanationMixin

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()[source]
Returns

None.

get_rule(path)[source]
Parameters

path (TYPE) – DESCRIPTION.

Returns

DESCRIPTION.

Return type

TYPE

get_text()[source]
Returns

DESCRIPTION.

Return type

TYPE

explainy.utils.utils module

Created on Sun Jan 17 19:34:15 2021

@author: maurol

explainy.utils.utils.create_folder(path)[source]

create folder, if it doesn’t already exist

explainy.utils.utils.create_one_hot_sentence(feature_name, feature_value, sentence)[source]

Create sentence from one-hot-encoded feature value, split the column name into feature and value and create sentence based on if the value was 1 = True, or 0 = False

Parameters
  • feature_name (TYPE) – DESCRIPTION.

  • feature_value (TYPE) – DESCRIPTION.

  • sentence (TYPE) – DESCRIPTION.

Returns

DESCRIPTION.

Return type

sentence_filled (TYPE)

Module contents