Exploring Streamlit or Dash to build specific Interactive Web Applications
As a PO, I am not wondering anymore if the Python/AI/ML revolution is a new fad or a real trend? That’s both of it! Like anyone who start something new like I do now with Python and IA, I am currently in the “enthusiastic phase” that tend to transmogrify me as an overzealous supporter like cucumbers are ultimately transmogrified into pickles!
You can find the code on my github account:
- Exploring Streamlit: build_interactive_webapps_python_scripts_using_streamlit
- Exploring Dash: build_interactive_webapps_python_scripts_using_dash
You can also watch the videos:
- Part 1 – Exploring Streamlit or Dash to build specific Interactive Web Applications
- Part 2 – Exploring Streamlit or Dash to build specific Interactive Web Applications
Anyway, this learning process is not without consequences, it definitely calls into question my PO’s practices, habits and skills. Am I a conservative with a fixed mindset ? Or do I accept changes as necessary and essential even though it may say leaving my comfort zone to a more exploratory area! It is almost a cliché dilemma!
I know that all technologies are doomed to disappear or to be replaced. Regarding Python’s potential, the question has
become more and more acute “Will I be, from 1 or 2 years from now, an has-been P.O, knowing only deprecated technology if I do not tackle right now the Python/AI/ML revolution?”. I guess I will answer YES.
By experience, I know also that it is not a direct threat but a progressive one. I heard that meanwhile Python is
steadily progressing, PHP for instance remains popular mostly
due to the 2 killer apps named WordPress and Drupal, legacy! Even though, there are some smoke screen effects due to local exceptions e.g. French development labour market dominated
by Symfony for instance or the worldwide Laravel spectacular breakthrough.
I do not know if It can be considered as a forerunner sign for the actual or future Python hegemony but just google for instance the result number on
Manichean comparisons such as “PHP vs Python”, you’ll be surprised!
Lastly, here is 2 videos, that are addressing this concern on this future trend. The first video is in brazilian, a quite personal testimony but it remains interesting both for practising brazilian and hearing few arguments. The second video gives a very macro vision and quite technical but with a huge historical depth and that’s quite interesting even though a bit technical.
- PHP vale a pena? (minha opinião sincera) https://www.youtube.com/watch?v=H43fXodv6WY
- Why Isn’t Functional Programming the Norm? – Richard Feldman https://www.youtube.com/watch?v=QyJZzq0v7Z4
After, the few thoughts, let’s get down to earth!
Professionally, I am a bit utilitarian. Learning something new like Python and IA has to “payback” somehow. I always try to figure out what can I gain from this experience and how can I apply this knowledge on a daily basis before starting up. Sometimes it even turns ridiculous! I must also confess that I didn’t go that far as the guy behind keypressingmonkey*.
See Everything I Automated In 2020 To Save Me Hours Of Time by https://keypressingmonkey.medium.com/. There is also this very truthful testimony about learning coding in I Learned Coding Mostly From Porn
In the meantime, I always deal with these 2 safeguards: obsolescence and time-to-market.These 2 concepts can be sumarized with 1 question: “Is there a purpose to learn something that will be soon deprecated?”. Despite all this questioning, I preserve to learn Python/AI/ML. As a conclusion, what I am looking for in term of feature may require to drop PHP as the only main programming language and turn my known developing paradigm upside down.
So, that is the reason why I have explored especially the ability with Python to build-up quickly applications, leveraging on these 2 python libraries :
- Streamlit https://streamlit.io/
- Plotly Dash
https://dash.plotly.com/
This post is my feedback on this experience. Enough conceptual bullshit! Let’s get straight to the point with examples.
My idea is to build a Dashboard in Python, quickly and on-demand, with an existing framework such as Plotly Dash or Streamlit to address a specific need. So, it suppose that you are able to quickly perform the following tasks:
- Leveraging intensively on a low-code with library like Streamlit or Plotly Dash
- Quickly and gently retrieving and consolidating heterogeneous data from different sources : mysql dump, csv, pickle, static json file, WP API…
- Focusing on a very SPA (Single Page Application) approach, respecting the single idea rule: one need, one feature, one screen, one application.
In this exploratory phase, shoddy work is even acceptable so you can focus on feature and value and not on development! But by choosing such a library, it is also picking a great foundation on which you can build any of your application with a relative good manufacturing quality.
Let’s browse some examples.
1. Streamlit
It is truly the ultimate Plug and Play tool for forging an application in data science. Once the installation is done! Creating an app is almost immediate and you obtain a rather conclusive result especially liked with few other libraries (Pandas, Spacy).
You can check the files from my github account.
In comment, in each file, how to launch the python script and the source.
#!/usr/bin/python # -*- coding: utf-8 -*- """ [path] cd /Users/brunoflaven/Documents/01_work/blog_articles/build_interactive_webapps_python_scripts_using_streamlit/02_interactive_webapps_streamlit/ [file] streamlit run 001_interactive_webapps_streamlit_pandas.py # more on infos and apps on https://streamlit.io/ https://streamlit.io/gallery https://docs.streamlit.io/en/stable/ """ # Source :: ! ARTICLE_1 How to write Web apps using simple Python for Data Scientists? Check https://mlwhiz.com/blog/2019/12/07/streamlit/ |
1.1 Streamlit and Pandas
It requires csv files that are in /datas/
. We have gather few csv that gather on one file countries, capital and continent from different sources.
001_interactive_webapps_streamlit_pandas.py 002_interactive_webapps_streamlit_pandas.py 003_interactive_webapps_streamlit_pandas.py 003a_interactive_webapps_streamlit_pandas.py 003b_interactive_webapps_streamlit_pandas.py 003c_interactive_webapps_streamlit_pandas.py 004d_interactive_webapps_streamlit_pandas.py 006_interactive_webapps_streamlit_pandas.py 007_interactive_webapps_streamlit_pandas.py data |
Source for the countries and some other infos about countries:
- https://stefangabos.github.io/world_countries/
- https://github.com/dbouquin/IS_608/blob/master/NanosatDB_munging/Countries-Continents.csv
1.2 Streamlit and Spacy
002_streamlit_for_nlp_projects_streamlit_spacy.py 003_streamlit_for_nlp_projects_text_summarization.py bf_sample_text_1.txt capture_1_003_streamlit_for_nlp_projects_text_summarization.png capture_2_003_streamlit_for_nlp_projects_text_summarization.png capture_streamlit_for_nlp_projects_streamlit_spacy.png cowboy_silhouette_2.png |
2. Dash
To me, Dash is closer to Flask. So, it is closer to a small, lightweight Python web framework to create a website. Still, I have gathered few examples that enable a comparison with Streamlit. There are very convincing examples if you need to prototype quickly a web application.
Definitely, Dash enables you to make great things but the learning curb is much steep and it sounds more like learning a way to create real websites with all the issues, especially nice UX for your IHM.
Nevertheless, I selected 2 impressive projects that show Dash extraordinary potential. It is sure that it can be a strong alternative to a PHP framework like Symfony or Laravel to create an in-house CMS like the one I am dealing with for instance as it integrates like a charm Data Science features.
Files examples from my github account
001_plotly_interactive_webapps_dash.py 002_plotly_interactive_webapps_dash.py 003_interactive_webapps_dash.py 003_plotly_interactive_webapps_dash.py 004_interactive_webapps_dash.py 005_interactive_webapps_dash.py 006_interactive_webapps_dash.py 007_interactive_webapps_dash.py 008_interactive_webapps_dash.py 009_interactive_webapps_dash.py |
The 2 great projects that leverage on Dash:
- Project #1: NLP visualizations for clear, immediate insights into text data and outputs
https://medium.com/plotly/nlp-visualisations-for-clear-immediate-insights-into-text-data-and-outputs-9ebfab168d5b - Project #2: NLP visualizations for clear, immediate insights into text data and outputs
https://github.com/giancarlotorres22/nlp-projeto-2/
Conclusion
Regarding what I was looking for, I’d rather go with Streamlit. That is great tool to extend life to some of my python scripts transforming them into an application that is sharable with anyone including customers. The existence of a Framework like Streamlit greatly facilitates the design and creation of a web application. It makes a serious alternative to all frameworks and already appeals to more than one team or PO. Obviously, this is not just a fad as it might have been in its days RoR for instance.
More infos
- Streamlit – The fastest way to build and share data apps
https://streamlit.io/ - Streamlit – Gallery
https://streamlit.io/gallery - Streamlit – Documentation
https://docs.streamlit.io/en/stable/ - Streamlitopedia :: Collection of tools, code snippets when making streamlit apps.
https://pmbaumgartner.github.io/streamlitopedia/ - (Simple and Efficient) Building Web Applications with Streamlit for NLP Projects
https://towardsdatascience.com/building-web-applications-with-streamlit-for-nlp-projects-cdc1cf0b38db - nomodulenamed. – I’ve installed the package using pip, but I got “ImportError: No Module Named [x]”
https://nomodulenamed.com/a/I-have-installed-the-package-using-pip - jonathanreadshaw – streamlit-twitter-stream
https://github.com/jonathanreadshaw/streamlit-twitter-stream - BERT For Measuring Text Similarity
https://towardsdatascience.com/bert-for-measuring-text-similarity-eec91c6bf9e1 - Summaryman; Text Summarization using Gensim and FastAPI
https://boadziedaniel.medium.com/summaryman-text-summarization-using-gensim-and-fastapi-fef710e16bc6
- Gensim
https://radimrehurek.com/gensim/index.html - Building A Natural Language Processing App with Streamlit,SpaCy and Python
https://blog.jcharistech.com/2019/10/22/building-a-natural-language-processing-app-with-streamlitspacy-and-python/ - Build A Text Summarization App Using Streamlit in 30 Minutes
https://pythonsimplified.com/build-a-text-summarization-app-using-streamlit-in-30-minutes/ - Text Summarization using a Wordcloud & Deployed on Streamlit
https://medium.com/analytics-vidhya/text-summarization-using-a-wordcloud-deployed-on-streamlit-cbce2f411c24 - Generating Fake Dating Profiles for Data Science
https://towardsdatascience.com/generating-fake-dating-profiles-for-data-science-cd3b929972bc - Using NLP Machine Learning on Dating Profiles
https://medium.com/swlh/using-nlp-machine-learning-on-dating-profiles-1d9328484e85 - How to Use Machine Learning and AI to Make a Dating App
https://towardsdatascience.com/dating-algorithms-using-machine-learning-and-ai-814b68ecd75e - Github from mdipietro09
https://github.com/mdipietro09 - Text Analysis & Feature Engineering with NLP
https://towardsdatascience.com/text-analysis-feature-engineering-with-nlp-502d6ea9225d - Building a Live Tweet Dashboard using Tweepy, MySQL and Streamlit
https://towardsdatascience.com/tracking-the-race-for-10-downing-street-live-tweet-dashboard-using-tweepy-mysql-and-streamlit-6084e88b4dd8 - Using Streamlit and Firestore to create a serverless web app with persistent data, written entirely in Python!
https://blog.streamlit.io/streamlit-firestore/ - Building Multi Page Web App Using Streamlit
https://medium.com/@u.praneel.nihar/building-multi-page-web-app-using-streamlit-7a40d55fa5b4 - Build a Simple CRUD Blog with Streamlit and Python
https://blog.jcharistech.com/2020/05/21/build-a-simple-crud-blog-with-streamlit-and-python/ - Streamlit Python Tutorial(Crash Course)
https://blog.jcharistech.com/2019/10/20/streamlit-python-tutorial-crash-course/ - Streamlit Themes – How to Customize Your Streamlit Apps
https://blog.jcharistech.com/2021/03/19/streamlit-themes-how-to-customize-your-streamlit-apps/ - A Beginners Guide To Streamlit
https://www.geeksforgeeks.org/a-beginners-guide-to-streamlit/ - imadelh – Bigquery-Streamlit
https://github.com/imadelh/Bigquery-Streamlit - changing anything in CSV – csvkit is a suite of command-line tools for converting to and working with CSV, the king of tabular file formats.
https://csvkit.readthedocs.io/en/latest/ - Tutorials for Python and SEO by importsem
https://importsem.com/ - Auto-SEO forecasting with StreamProphet! 🚀
https://www.charlywargnier.com/post/auto-seo-forecasting-with-streamprophet - Using Streamlit to create interactive WebApps from simple Python scripts
https://medium.com/swlh/using-streamlit-to-create-interactive-webapps-from-simple-python-scripts-f78b08e486e7 - Data Science Apps Using Streamlit
https://www.geeksforgeeks.org/data-science-apps-using-streamlit/ - How to Use Streamlit to Make a Website
https://towardsdatascience.com/how-to-use-streamlit-to-create-web-applications-218af44064f5 - How to Make a Website with Python and AWS
https://towardsdatascience.com/creating-a-website-to-host-your-python-web-application-f06f694a87e8
- Python_For_SEO (seo python)
https://github.com/jamesaphoenix/Python_For_SEO/ - Google Keyword Ranking Check with Python
https://github.com/sundios/Google-rank-tracker - Data Science Apps Using Streamlit Ressources
https://github.com/jcchouinard/SEO-Dashboard - Deploy Code With Streamlit
https://towardsdatascience.com/deploy-code-with-streamlit-90090b611f3c - How to write Web apps using simple Python for Data Scientists?
https://mlwhiz.com/blog/2019/12/07/streamlit/ - Using Streamlit to create interactive WebApps from simple Python scripts
https://medium.com/swlh/using-streamlit-to-create-interactive-webapps-from-simple-python-scripts-f78b08e486e7 - A Guide to Streamlit — Frontend for Data Science Made Simpler
https://towardsdatascience.com/a-guide-to-streamlit-frontend-for-data-science-made-simpler-c6dda54e3183 - 6 Jobs You Can Land If You Learn Python
https://learn.onemonth.com/6-jobs-you-can-land-if-you-learn-python/ - Create a data explorer app
https://docs.streamlit.io/en/stable/tutorial/create_a_data_explorer_app.html - A HANDS-ON INTRODUCTION TO STREAMLIT COMPONENTS
https://streamlit-components-tutorial.netlify.app/ - Streamlit with Image Processing Techniques and Object Detection Algorithms
https://towardsdatascience.com/image-processing-using-streamlit-d650fb0ccf8 - Automatically Find SEO Interlinking Opportunities with Python
https://importsem.com/automatically-find-seo-interlinking-opportunities-with-python/
- Interactive Web App with Streamlit and Scikit-learn
https://github.com/python-engineer/streamlit-demo - Step by step – first streamlit web app using python with conda distribution
https://www.youtube.com/watch?v=FxEFJP9m3ww - A Beginners Guide To Streamlit – Convert Python Code Into An App
https://analyticsindiamag.com/a-beginners-guide-to-streamlit-convert-python-code-into-an-app/ - Building a Bioinformatics Web App in Python | Streamlit #7
https://www.youtube.com/watch?v=iZUH1qlgnys - Create a Streamlit Component
https://docs.streamlit.io/en/stable/streamlit_components.html#part-1-setup-and-architecture - How to build a Streamlit component – Part 1: Setup and Architecture
https://www.youtube.com/watch?v=BuD3gILJW-Q - NLP visualizations for clear, immediate insights into text data and outputs
https://medium.com/plotly/nlp-visualisations-for-clear-immediate-insights-into-text-data-and-outputs-9ebfab168d5b - Flask
https://flask.palletsprojects.com/en/2.0.x/ - plotly – dash-sample-apps
https://github.com/plotly/dash-sample-apps - Search “streamlit nlp” on duckduckgo.com
https://duckduckgo.com/?q=streamlit+nlp&atb=v252-1&ia=web - Performance on dash.plotly.com
https://dash.plotly.com/performance - dashdub – Convert speech to text with Dash & Python
https://github.com/plotly/dashdub - Dash AV Video Detection
https://dash-gallery.plotly.host/dash-video-detection/ - Dash Enterprise – The premier low-code platform for ML & data science apps.
https://plotly.com/ - Plotly Dash Development Tips by Mátyás Budavári
https://budavariam.github.io/posts/2021/04/05/plotly-dash-development-tips/ - Excellent article – Dash for Beginners – Derrick Mwiti
https://www.datacamp.com/community/tutorials/learn-build-dash-python - Excellent – greatest documentation ever – Cheat Sheets
https://www.datacamp.com/community/data-science-cheatsheets
- How To Build A Dashboard In Python – Step-by-Step Tutorial
https://www.statworx.com/en/blog/how-to-build-a-dashboard-in-python-plotly-dash-step-by-step-tutorial/ - Gary Snyder
https://en.wikipedia.org/wiki/Gary_Snyder
Streamlit
Articles Serie from Marco Santos