Predicting Risk with CatBoost
You can get started with explainX in less than five minutes. Just follow this working examples line by line or simply copy-paste the code in your Jupyter Notebook

Goal

For this example, our goal is to predict RiskPerformance from the HELOC dataset.
For this example, we will be trainingCatBoost Classifierand then use ExplainX to provide business-level explanations and performing debugging tasks.
Let's start by opening up our Jupyter Notebook.
Install relevant packages
1
!pip install catboost
2
!pip install explainx
Copied!
Import the library
1
from explainx import *
2
import catboost
3
from sklearn.model_selection import train_test_split
Copied!
Load and pre-process the dataset for model-building. The dataset can be easily accessible from within the explainX library.
1
#Load Dataset
2
X_Data, Y_Data = explainx.dataset_heloc()
3
4
#Split data into train and test
5
X_train, X_test, Y_train, Y_test = train_test_split(X_Data, Y_Data, test_size=0.2, random_state=0)
6
Copied!
Let's train our CatBoost model.
1
#Run CatBoost Model
2
model = CatBoostClassifier(iterations=500, learning_rate=0.3, depth=2)
3
4
#Fit Model
5
model.fit(X_train.to_numpy(), Y_train)
Copied!
Let's call the explainX function and pass the parameters.
1
explainx.ai(X_Test, Y_Test, model, model_name="catboost")
Copied!
Once the explainX function is done running, you can simply click on the application link to access the explainX dashboard.
1
App running at https://127.0.0.1:8050
Copied!
In the next part, we will continue our predicting RiskPerformance with CatBoost example. Let's dive right into explaining the model behavior and model predictions.
Last modified 1yr ago
Export as PDF
Copy link