Black Lives Matter. Please consider donating to Black Girls Code today.
Learn about the upcoming Dash Enterprise 4.0 release in the August 5th webinar with Chris Parmer, the Inventor of Dash.

Show & Tell - Dash Loan Grade Classification with Snowflake

Summary

More Details

If you’ve been following the forum, you probably noticed the Interest Rate app I made using Dash and Snowflake DBs. This time, rather than showing how to train a Machine Learning model, I show you how to use pre-trained Decision Tree Classifiers to perform real-time predictions on tabular data (information about a loan applicant that was recorded by a lending firm).

You can imagine that each table contains anonymized information about a distinct customer segment (e.g. potential clients that are renting apartments, that are paying mortgage on their house, or that fully own their house). Whenever you change the value of the dropdown, a query is automatically generated based on what you selected, and sent to a Snowflake database to retrieve the first 100 records. Once this is done, the result of the query is stored in a dcc.Store.

Now, notice that, by clicking on the previous or next sample, the predicted grade and the values in the table change. Essentially, the table contains all the features that are taken into consideration by the model. Every time you click the “next” or “prev” buttons, a decision tree model is loaded into memory, a record is retrieved from a dcc.Store and the model ingests the new input (e.g. information collected about a potential client) to predict the loan grade that would be assigned to them.

Finally, you can also explore the decision path that the model takes to make each prediction. Since we trained a few different models (which you can select in the rightmost dropdown), the tree will look a bit different in every case. By navigating through the graph, you can analyze why the model decided to give a certain grade based on the criterion used to split at every level. In addition, at every split, you can see the proportion of the training set that actually had that grade based on all criteria in the path; with this information, you can determine if the grade that was assigned by the model is highly probable, or should be reconsidered.

In conclusion, this app shows you how to leverage highly reliable cloud-based databases (Snowflake) for creating interpretable Machine Learning models (in this case, a decision tree).

1 Like