lime_xgboost

Simple package for creating LIMEs for XGBoost

class lime_xgboost.lime_explainer.LIMEExplainer(training_frame=None, X=None, model=None, N=None, discretize=None, quantiles=None, seed=None, print_=None, top_n=None, intercept=None)

Bases: object

Basic framework for building Local, Interpretable, Model-agnostic Explanations (LIMEs) for XGBoost models. Supports regression and binomial classification. Requires h2o, numpy, pandas, and xgboost packages.

Variables:
  • training_frame – Pandas DataFrame containing the row to be explained, mandatory.
  • X – List of XGBoost model inputs. Inputs must be numeric, mandatory.
  • model – Trained XGBoost booster to be explained, mandatory.
  • N – Size of LIME local, perturbed sample. Integer, default 10000.
  • discretize – Numeric variables to discretize. List, default X.
  • quantiles – Number of bins to create in numeric variables. Integer, default 4.
  • intercept – Whether local linear models should include an intercept. Boolean, default True. (EXPERIMENTAL)
  • seed – Random seed for enhanced reproducibility. Integer, default 12345.
  • print – Whether to print a table of local contributions (reason codes) and plot top_n local contributions (reason codes). Boolean, default True.
  • top_n – Number of highest and lowest Local contributions (reason codes) to plot. Integer, default 5.
  • reason_code_values – Pandas DataFrame containing local contributions (reason codes) for model and row to be explained.
  • lime_r2 – R2 statistic for trained local linear model, float.
  • lime_pred – Prediction of trained local linear model for row of interest.
  • lime – Trained local linear model, H2OGeneralizedLinearEstimator.
  • bins_dict – Dictionary of bins used to discretize the LIME sample.

Reference: https://arxiv.org/abs/1602.04938

explain(row_id)

Executes lime process.

Parameters:row_id – The row index of the row in training_frame to be explained.