omnixai.explainers.tabular package
omnixai.explainers.tabular.base module
- class omnixai.explainers.tabular.base.TabularExplainerMixin
Bases:
object
- class omnixai.explainers.tabular.base.TabularExplainer(training_data, predict_function, mode='classification', **kwargs)
Bases:
ExplainerBase,TabularExplainerMixinThe base class of model-agnostic explainers for tabular data.
- Parameters
training_data (
Tabular) – The data used to initialize the explainer.predict_function (
Callable) – The prediction function corresponding to the model to explain. When the model is for classification, the outputs of thepredict_functionare the class probabilities. When the model is for regression, the outputs of thepredict_functionare the estimated values.mode (
str) – The task type, e.g., classification or regression.kwargs – Additional parameters.
- class omnixai.explainers.tabular.base.SklearnBase(mode='classification', cate_encoder=<omnixai.preprocessing.encode.OneHot object>, cont_encoder=<omnixai.preprocessing.normalize.Standard object>, target_encoder=<omnixai.preprocessing.encode.LabelEncoder object>, **kwargs)
Bases:
ExplainerBase,BaseEstimatorThe base class of model-specific explainers for scikit-learn models.
- Parameters
mode (
str) – The task type, e.g., classification or regression.cate_encoder (
TransformBase) – The encoder for categorical features, e.g., OneHot, Ordinal.cont_encoder (
TransformBase) – The encoder for continuous-valued features, e.g., Identity, Standard, MinMax, Scale.target_encoder (
TransformBase) – The encoder for targets/labels, e.g., Identity for regression, LabelEncoder for classification.
- fit(training_data, train_size=0.8, **kwargs)
Trains the model given the training dataset.
- Parameters
training_data (
Tabular) – The training dataset.train_size (
float) – Used in train-test splits, i.e., the proportion of the training samples.
- predict(X)
Predicts targets or labels.
- Parameters
X (
Tabular) – The test dataset.- Returns
The predictions.
- Return type
np.ndarray
- predict_proba(X)
Predicts class probabilities in classification.
- Parameters
X (
Tabular) – The test dataset.- Returns
The predicted class probabilities.
- Return type
np.ndarray
- class_names()
Returns the class names in classification.
- Returns
The class names.
- Return type
List
omnixai.explainers.tabular.auto module
- class omnixai.explainers.tabular.auto.TabularExplainer(explainers, mode, data, model, preprocess=None, postprocess=None, params=None)
Bases:
AutoExplainerBaseThe class derived from AutoExplainerBase for tabular data, allowing users to choose multiple explainers and generate different explanations at the same time.
explainers = TabularExplainer( explainers=["lime", "shap", "mace", "pdp"], mode="classification", data=data, model=model, preprocess=preprocess_function, postprocess=None, params={ "lime": {"kernel_width": 3}, "shap": {"nsamples": 100}, "mace": {"ignored_features": ["Sex", "Race", "Relationship", "Capital Loss"]} } ) local_explanations = explainers.explain(x) global_explanations = explainers.explain_global()
- Parameters
explainers (
Collection) – The names or alias of the explainers to use.mode (
str) – The task type, e.g. classification or regression.data (
Tabular) – The training data used to initialize explainers.datacan be the training dataset for training the machine learning model. If the training dataset is large,datacan be its subset by applying omnixai.sampler.tabular.Sampler.subsample.model (
Any) – The machine learning model to explain, which can be a scikit-learn model, a tensorflow model, a torch model, or a black-box prediction function.preprocess (
Optional[Callable]) – The preprocessing function that converts the raw input features into the inputs ofmodel.postprocess (
Optional[Callable]) – The postprocessing function that transforms the outputs ofmodelto a user-specific form, e.g., the predicted probability for each class.params (
Optional[Dict]) – A dict containing the additional parameters for initializing each explainer, e.g., params[“lime”] = {“param_1”: param_1, …}.
- static list_explainers()
List the supported explainers.
Subpackages
- omnixai.explainers.tabular.agnostic package
- omnixai.explainers.tabular.agnostic.lime module
- omnixai.explainers.tabular.agnostic.shap module
- omnixai.explainers.tabular.agnostic.pdp module
- omnixai.explainers.tabular.agnostic.ale module
- omnixai.explainers.tabular.agnostic.sensitivity module
- omnixai.explainers.tabular.agnostic.L2X.l2x module
- omnixai.explainers.tabular.agnostic.permutation module
- omnixai.explainers.tabular.agnostic.shap_global module
- omnixai.explainers.tabular.agnostic.bias module
- omnixai.explainers.tabular.agnostic.gpt module
- omnixai.explainers.tabular.counterfactual package
- omnixai.explainers.tabular.specific package