ExpyBox

ExpyBox is a Jupyter toolbox for model interpretability/explainability. It lets you create interactive Jupyter notebooks to explain your model. Because of alibi package ExpyBox requires 64-bit Python 3.7 or higher.

It is also recommended to create separate virtual enviroment - you can use venv.

Otherwise the installation process is the same as for other packages, just use pip:

pip install expybox

API reference

class expybox.ExpyBox(train_data, predict_function, kernel_globals=None, categorical_names=None, mode='classification', class_names=None, feature_names=None)

Main class to instantiate and hold global data like predict_function, train_data and so on.

Parameters
  • train_datanumpy array or pandas dataframe of shape (#instances, #features) Data used to explain models (for methods that require data) and to offer instances from (when building instance). Categorical features need to be label_encoded into integers starting from 0. One-hot encoding is not currently supported.

  • predict_functionCallable Predict function of a model. In case of classification it should return probabilities of classes for each class. Needs to be able to deal with numpy array with shape (#instances, #features). If that’s not the case for your model, I recommend writing a wrapper function and pass that one.

  • kernel_globalsdict A dictionary with name_of_variable: variable (NOT its value!) from your kernel. Used to enable passing variable declared in your Jupyter notebook as a value to certain fields. You can either create this dictionary yourself (if you know what you’re doing) or just use globals() (this is the recommended usage as it updates when you declare new variable and you don’t need to care about it - i.e. just do … kernel_globals=globals(), …)

  • categorical_namesdict A dictionary with index_of_feature: list of the names for categorical features. For example if n-th feature of train_data (train_data[:, n]) is categorical the dict entry should look like this: {n: [name_if_0, name_if_1, name_if_2, … ]} Used for better readability and determining which features are categorical, which improves some methods.

  • mode‘classification’ or ‘regression’

  • class_nameslist Names for output classes in order in which the predict_function returns probabilities for them. Used just to make input and output more human-friendly

  • feature_nameslist Names for features in order of appearing in train_data. If not filled and train_data is an instance of pandas.DataFrame, train_data.columns is used. Used to make input and output more human-friendly

Indices and tables