Web Application added to do the prediction
This web application connects to InterSystems Cloud SQL to create, train, validate, and predict ML models, make Predictions and display a dashboard of all the trained models with an explanation of the workings of a fitted machine learning model. The dashboard provides interactive plots on model performance, feature importances, feature contributions to individual predictions, partial dependence plots, SHAP (interaction) values, visualization of individual decision trees, etc.
The Application includes the following:
We will follow the below steps to create and view the explainer dashboard of a model :
So Let us start with first Step
Create folder and Clone/git pull the repo into any local directory
git clone https://github.com/mwaseem75/iris-mlm-explainer.git
Log in to InterSystems Cloud Service Portal Select the running deployment
Click on Add and Manage Files Repo contains USA_Housing_tables_DDL.sql(DDL to create tables), USA_Housing_train.csv(training data), and USA_Housing_validate.csv(For validation) files under the datasets folder. Select the upload button to add these files.
Click on Import files, then click on DDL or DML statement(s) radio button, then click the next button Click on Intersystems IRIS radio button and then click on the next button Select USA_Housing_tables_DDL.sql file and then press the import files button Click on Import from the confirmation dialog to create the table Click on SQL Query tools to verify that tables are created
Click on Import files, then click on CSV data radio button, then click the next button Select USA_Housing_train.csv file and click the next button Select USA_Housing_train.csv file from the dropdown list, check import rows as a header row and Field names in header row match column names in selected table and click import files click on import in the confirmation dialog click on import in the confirmation dialog Make sure 4000 rows are updated Do the same steps to import USA_Housing_validate.csv file which contains 1500 records
Click on IntegratedM tools and select Create Panel.
Enter USAHousingPriceModel in the Model Name field, Select usa_housing_train table and Price in the field to predict dropdown. Click on create model button to create the model
select Train Panel, Select USAHousingPriceModel from the model to train dropdownlist and enter USAHousingPriceModel_t1 in the train model name field Model will be trained once Run Status completed
Select Validate Panel, Select USAHousingPriceModel_t1 from Trained model to validate dropdownlist, select usa_houseing_validate from Table to validate model from dropdownlist and click on validate model button Click on show validation metrics to view metrics Click on the chart icon to view the Prediction VS Actual graph
Repository already contains python virtual environment folder (venv) along with all the required libraries.
All we need is to just activate the environment On Unix or MacOS:
$ source venv/Scripts/activate
Run the below command in virtual environment to start our main application
Navigate to http://127.0.0.1:5000/ to run the application
Put same values used in InterSystems Cloud SQL
Enter Age of house, No of rooms, No of bedroom and Area population to get the prediction
Finaly, run the below command in virtual environment to start our main application
Navigate to http://localhost:8050/ to run the application
Application will list all the trained models along with our USAHousingPriceModel. Navigate to "go to dashboard" hyperlink to view model explainer
Feature Importances. Which features had the biggest impact?
Quantitative metrics for model performance, How close is the predicted value to the observed?
Prediction and How has each feature contributed to the prediction?
Adjust the feature values to change the prediction
Shap Summary, Ordering features by shap value
Interactions Summary,Ordering features by shap interaction value
Decision Trees, Displaying individual decision trees inside Random Forest
We can also use jupyter notebook to create,train,validate and predict ML model if not created by using Cloud SQL Service Portal
Repo also contains USAHousingModelNotebook.ipynb Jupyter notebook. In order to run it, just run runnotebook.bat under venv environment
Navigate to http://localhost:8888/ to run the notebook open USAHousingModelNotebook.ipynb notebook by clicking on it
NOTE : Make sure to select venv kernal by selecting main menu Kernal>Change kernal>venv, so that notebook will use virtual environment libraries
NOTE : Run the cells in sequence by just clicking the small arrow
USA Housing dataset is taken from Kaggle
USA_Housing dataset contains the following columns:
This application is derived from the isc-cloud-sql-python-demo template by @Evgeny Shvarov
Web Application added to do the prediction