Interactive ML – Clustering (KMeans) via Streamlit

In the modern days of ML, and the improved understanding of the business users with the concepts of  ML. Everyone is curious to gain insights from the combinations of varied parameters, feature’s and inputs to the model and evaluate the output.

In order to address the growing needs of not just one off static outcomes of ML experiments, we have now trended to build the user interactive application leveraging Streamlit.

This is a great new addition to our portfolio of tools and reporting around leveraging ML. The package has all the right necessary ingredients to roll out our business ready applications.

In the sample screenshot illustrated below the users are able to select the date rage from when the analysis should run for store profiling and clustering. And the resulting output is presented on the right (chart + data).

(Note: The above data is randomly generated data for illustration purposes only) 

In the above Streamlit app, the process flow is as follows:

  1. The user selects the parameters they wish to run analysis on from the UI
  2. Based on the above parameters the data is fetched from the Database servers into Pandas DF, also leveraging the caching/sessions to improve speed
  3. The KMean’s cluster is applied on the dataset received
  4. The dataset then feeds the graphing component (powered by matplotlib)
  5. Finally the objects are composed and rendered on the Streamlit UI

The key takeaway from the above methodology are as follows:

  • The Streamlit is a great platform for quick build outs of application which are business friendly
  • This can be used as a great interface to build out interactive experiments pipeline where tweaking of varied parameters/inputs can reflect changes on the output
  • The development is very easy and clear documentation helps a lot

I hope the above concept helps the similar other use cases where the repetitive experimentation require code changes and provides users a more interactive way to collaborate with the ML models and their inputs.

Happy to connect and share experiences within the space !!

Leave a Reply

Your email address will not be published. Required fields are marked *