Unveiling the Black Box: Leveraging Streamlit for Enhanced Artificial Intelligence Explainability

Carmel Zolkov
NI Tech Blog
Published in
7 min readAug 14, 2023

In the realm of artificial intelligence (AI), understanding the decision-making process behind machine learning models is critical. The concept of Explainable AI (XAI) has emerged as a key focus, allowing us to shed light on the black box and gain insights into the inner workings of these models.

This article is the first part of a blog series that explores how Streamlit, a powerful Python library for building interactive web applications, was leveraged to tackle challenges in enhancing XAI for different AI models.

This blog series will dive deep into the concept of Unveiling the Black Box, starting with the exploration of Streamlit’s role in enhancing explainability for one AI model. We will discuss the methodologies, techniques, and tools employed to unlock insights into the decision-making processes of machine learning models.

In the upcoming second part of this series, we will shift our focus to another AI model: Contextual Multi-Armed Bandits. We will explore how we formulated the right metrics and developed a separate app to enhance the explainability for this specific model. By examining the process of Analyzing and Defining Contextual Multi-Armed Bandits, we will uncover the inner workings of this algorithm and highlight the significance of XAI in its implementation.

Background: Natural Intelligence’s Machine learning Ranking Project

Natural Intelligence facilitates connections between highly motivated customers and top brands, providing them with a carefully curated and sorted list of recommended brands.

With the help of the data science team, this platform leverages cutting-edge ML models to achieve a remarkable feat: delivering a tailored list of the most fitting brands for each user within various categories, all through the power of personalization.

Ranking With The Help Of Personalization

AI personalization refers to the practice of leveraging artificial intelligence techniques to tailor and customize experiences, recommendations, and content to individual users based on their unique preferences, behaviors, and characteristics. It involves analyzing large amounts of data, including user interactions, past behaviors, demographics, and contextual information, to understand users’ needs and deliver personalized experiences or recommendations.

AI personalization algorithms utilize machine learning models to make predictions and decisions about what content or recommendations will be most relevant and engaging to each user. These algorithms continuously learn and adapt based on user feedback and new data, aiming to improve the accuracy and effectiveness of personalization over time.

Exploring Personalized Brand Rankings with Real-Life Scenarios

Example Scenario: Personalized Brand Rankings in the Travel Planning Assistance Domain.

In this example, we delve into the world of personalized brand rankings by examining the complex nature of selecting the top 10 best travel planning assistance sites for two individuals with distinct preferences. By exploring this scenario, we will gain valuable insights into the intricacies of the ranking project and showcase the power of AI personalization in catering to individual needs.

Our individuals are Emma and James. Emma is an adventurer, who loves activities such as hiking, mountain climbing, and bungee jumping. She enjoys budget-friendly options that allow her to stretch her travel budget to the fullest.

On the other hand, James is a luxury seeker that enjoys indulging in luxury experiences, staying in upscale hotels, and experiencing fine dining. He is willing to splurge to create unforgettable memories during his travels.

The ML models used in the personalized ranking project for travel planning assistance incorporate various features to cater to individual preferences.

Based on these features, the ML models generate personalized rankings for Emma and James, presenting them with a list of the top 10 travel destinations tailored to their individual preferences. The order of the brands in the list may differ for Emma and James, reflecting their unique interests and priorities within the travel domain.

The main Challenge: Breaking the Black Box & Enhancing the model’s Explainability

As you probably can imagine as described above, our models contain a large and complex amount of data regarding all our sites, visitors, brands, taking into account a lot of factors and many features.

This complexity poses a significant challenge when it comes to elucidating the decision-making process. While the business understandably seeks a comprehensive understanding of every model decision, navigating the intricacies of explaining these decisions becomes increasingly challenging due to the volume and complexity of the data involved.

The key to facilitating the growth and successful implementation of our data science projects lies in attaining improved explainability of the models’ outputs and their decision-making mechanisms.

As our product relies on machine learning models, we faced the challenge of understanding and explaining the decisions made by these models. Our stakeholders, including business teams and end-users, desired clear insights into how and why certain recommendations were made

And so, the question arises: How can we unravel the black box and gain a deep understanding of the decision-making process, provide insights and understand the logic that goes into the model’s decision-making?

We need an explainability platform that would allow both basic and in-depth insights and help explore the models behavior and decisions making.

Explainable AI (XAI) emerged as a crucial solution to these challenges.

Explainable AI: Shedding Light on the Black Box

Explainable AI involves techniques that enable us to understand and validate our models better. By incorporating additional metadata in the form of visual or textual guides, XAI provides insights into specific AI decisions and enhances the transparency and understanding of the model’s internal functionality of the model as a whole. The value of XAI lies in understanding the model driving factors, giving reasonable explanations of the model decisions, transparency and growing trust in the models, and empowerment of stakeholders.

Solution in 4 steps: Choosing the Tool, Defining Requirements, Design, and Development

The first step in our solution was carefully choosing Streamlit as the foundation for developing our eXplainable AI (XAI) application. Streamlit’s clean and visually appealing interface, combined with its capability to present data and enable interaction, made it an ideal choice to enhance the explainability of our AI systems.

Moving forward, the second step involved defining our requirements with utmost precision. This entailed clearly identifying the specific functionalities and features that our XAI application needed to possess in order to provide comprehensive insights into our machine learning models. We Characterize the design of the application by preparing detailed wireframes, ensuring that all essential aspects were taken into account.

With a solid understanding of our requirements, we transitioned to the third step: the design phase. This involved translating our wireframes and design specifications into a tangible application that would seamlessly integrate with our existing infrastructure. By leveraging Streamlit’s capabilities, we were able to create a user-friendly and intuitive interface that facilitated both basic observations and in-depth analysis of the automation performance.

Lastly, we ventured into the development phase, bringing our design to life. Streamlit’s versatility and ease of use allowed us to swiftly transform our vision into a fully functional XAI application.

The end-to-end nature of this project was truly remarkable, encompassing everything from product characterization to production.

Personalized Ranking HUB

This app offers a seamless user experience, complete with a welcome screen that introduces the app’s functionalities and a range of pages to cater to the needs of various stakeholders. From the management summary page providing an overview of key performance indicators (KPIs) to detailed chart analysis pages segmented by deployment phases, this app empowers management, analysts, product managers, and the dedicated data science (DS) team with valuable insights.

The Management Summary: The app’s first page, which offers a comprehensive snapshot of the current deployment automations. This page acts as a management dashboard, presenting key KPIs such as deployment success rate, average deployment time, etc. By visualizing this data, management, analysts, and product managers gain an immediate understanding of the deployment landscape, facilitating informed decision-making.

The Chart Analysis — Deployments phase focuses on chart analysis for the actual deployment phase. Visualizations capture key metrics such as deployment success rates, performance indicators associated with deployed applications, and gain in-depth understanding of the underlying data. By examining these charts, stakeholders can monitor deployment effectiveness, identify opportunities for enhancement, and ensure seamless application delivery.

Wrap up:

Leveraging the power of Streamlit, we successfully tackled the challenges of enhancing explainability in AI systems. Streamlit’s interactive and intuitive nature played a vital role in providing transparency, empowering stakeholders, and fostering the development of trustworthy AI systems. Whether it was unraveling the black box of machine learning models in personalized ranking or enhancing the interpretability of other ML algorithms, Streamlit emerged as a valuable tool for demystifying complex AI algorithms. It offered a platform to promote trust and transparency in decision-making processes. Additionally, the application we built with Streamlit served as a one-stop-shop, providing a centralized location for controlling automation and offering valuable insights. This further enriched stakeholders’ understanding and confidence, encouraging them to take ownership and responsibility for the product.

The application empowered stakeholders to explore the behavior of the models and gain advanced insights into the factors contributing to recommendations.

Stay alert for the forthcoming second part, in which we will unveil the process behind creating a cutting-edge application aimed at improving the interpretability of contextual multi-armed bandits!

--

--