Starter Example

This is a basic example of explainX Open-Source usage in explaining an XGBoost model.

Open up your jupyter notebook and simply follow the code.


The goal is to be able to explain and debug the machine learning model we are building. The main goal will be to provide business-level explanations.


Make sure you have XGBoost & explainX installed. In case you don't, follow the following command to install the libraries.

!pip install xgboost==1.0.2
!pip install explainx

Running on Local Computer

#Import ExplainX Module
from explainx import *
import xgboost
#Load Dataset: X_Data, Y_Data
#X_Data = Pandas DataFrame
#Y_Data = Numpy Array or List
X_Data, Y_Data = explainx.dataset_boston()
#Train Model
model = xgboost.train({"learning_rate":0.01}, xgboost.DMatrix(X_Data, label=Y_Data),100)
#Call the ExplainX Function, Y_Data, model, model_name="xgboost")

Click on the link to view the dashboard and start explaining the model:

App running on

Running on the Cloud

If you are using Jupyter Notebook deployed on the cloud or online IDEs like Colab and AWS SageMaker, there is an extra step that you need to perform.

Open up your terminal and run the following commands:

$ lt -h "" -p [port number]