cft

Machine Learning Model Dashboard

Creating dashboards to interpret machine learning model


user

Himanshu Sharma

a year ago | 4 min read

Nowadays, creating a machine learning model is easy because of different python libraries that are in the market like sklearn, lazypredict, etc.

These libraries are easy to use and used to create different types of models along with different types of visualizations and finding out the model performance. If you don’t know how lazy predict works, check out the article given below.

The main challenge nowadays is that models are not interpreted easily which makes it difficult for a non-technical person to understand and interpret the logic and how the model is working.

Explainer dashboard is an open-source python library that creates machine learning model dashboards that can be used to easily understand and analyze the important factors on which the model is working like feature importance, model performance, visualizations, etc.

In this article, we will use an explainer dashboard to create machine learning dashboards and understand how the model is working.

Let’s get started…

Installing required libraries

We will start by installing an explainer dashboard using pip. The command given below will do that.

pip install explainerdashboard

Importing required libraries

In this step, we will import the required libraries and functions to create a machine learning model and dashboard.

from sklearn.ensemble import RandomForestClassifier
from explainerdashboard import ClassifierExplainer, ExplainerDashboard
from explainerdashboard.datasets import titanic_survive, titanic_names

Creating the Model & Dashboard

This is the final step in which we will create the machine learning model and then interpret that model by creating a dashboard.

  1. Creating Model
feature_descriptions = {
"Sex": "Gender of passenger",
"Gender": "Gender of passenger",
"Deck": "The deck the passenger had their cabin on",
"PassengerClass": "The class of the ticket: 1st, 2nd or 3rd class",
"Fare": "The amount of money people paid",
"Embarked": "the port where the passenger boarded the Titanic. Either Southampton, Cherbourg or Queenstown",
"Age": "Age of the passenger",
"No_of_siblings_plus_spouses_on_board": "The sum of the number of siblings plus the number of spouses on board",
"No_of_parents_plus_children_on_board" : "The sum of the number of parents plus the number of children on board",
}X_train, y_train, X_test, y_test = titanic_survive()
train_names, test_names = titanic_names()
model = RandomForestClassifier(n_estimators=50, max_depth=5)
model.fit(X_train, y_train)

2. Creating Dashboard

from sklearn.ensemble import RandomForestClassifier
from explainerdashboard import ClassifierExplainer, ExplainerDashboard
from explainerdashboard.datasets import titanic_survive, titanic_namesfeature_descriptions = {
"Sex": "Gender of passenger",
"Gender": "Gender of passenger",
"Deck": "The deck the passenger had their cabin on",
"PassengerClass": "The class of the ticket: 1st, 2nd or 3rd class",
"Fare": "The amount of money people paid",
"Embarked": "the port where the passenger boarded the Titanic. Either Southampton, Cherbourg or Queenstown",
"Age": "Age of the passenger",
"No_of_siblings_plus_spouses_on_board": "The sum of the number of siblings plus the number of spouses on board",
"No_of_parents_plus_children_on_board" : "The sum of the number of parents plus the number of children on board",
}X_train, y_train, X_test, y_test = titanic_survive()
train_names, test_names = titanic_names()
model = RandomForestClassifier(n_estimators=50, max_depth=5)
model.fit(X_train, y_train)explainer = ClassifierExplainer(model, X_test, y_test,
cats=['Deck', 'Embarked',
{'Gender': ['Sex_male', 'Sex_female', 'Sex_nan']}],
cats_notencoded={'Embarked': 'Stowaway'},
descriptions=feature_descriptions,
labels=['Not survived', 'Survived'],
idxs = test_names,
index_name = "Passenger",
target = "Survival",
)db = ExplainerDashboard(explainer,
title="Titanic Explainer",
shap_interaction=False,
)
db.run(port=8050)

In the video given below, I have shown the dashboard created using the explainer dashboards.

Dashboard(Source: By Author)

Dashboard Home Page(Source: By Author)
Dashboard Home Page(Source: By Author)
Dashboard(Source: By Author)
Dashboard(Source: By Author)

Here you can clearly visualize the dashboard create using the explainer dashboard. We can clearly analyze different properties of the model and other parameters.

Go ahead try this with different datasets and create beautiful dashboards to interpret the model. In case you find any difficulty please let me know in the response section.

This article is in collaboration with Piyush Ingale.

Originally Published on Towards Data Science.


Upvote


user
Created by

Himanshu Sharma


people
Post

Upvote

Downvote

Comment

Bookmark

Share


Related Articles