As a data enthusiast who have worked on a machine learning model. We want to deploy this solution for the general public use. So what options do we have ? We can use some python based framework to deploy our machine learning model.
What are my options?
Now you searched for some options available. You come across an arduous task of finalising frameworks like Flask, Dash, Streamlit, Django and many more
So the main question is which framework should we focus on.
Let us examine our main options in short
- Dash if you already use Python for your analytics and you want to build production-ready data dashboards for a larger company.
- Streamlit if you already use Python for your analytics and you want to get a prototype of your dashboard up and running as quickly as possible.
- Flask if you want to build your own solution from the ground up.
Let us focus on these framework one by one:
Flask
Flask is a python web framework which is used to build web applications. It offers several developer friendly modules for web development projects. Flask has resources to deploy a machine learning model in the form of web app, Through for Frontend, you would need proper development. There are components you can add to Flask, but you can easily create your own on the fly too. This means that as a data scientist, you must also be comfortable with HTML, CSS, and JavaScript.
Mainly Flask acts as a backend framework for the web apps. You are not just restricted to data apps.
Pros:
- As it is a framework, a user can build everything up from scratch as per requirements.
- Easier to build customizable applications.
- More generic web applications can be built using Flask.
- As Flask is considered much more stable and mature technology compared to peers.
- Active community support
- Extensive documentation and related libraries
- Multiple learning and practising resources online
Cons:
- Flask does not provide any sort of UI components for machine learning or data science applications.
- Intermediate Python knowledge is required, as well knowledge of HTML, CSS, and JavaScript.
- Building the solution from scratch can be resource intensive.
Dash
Dash is an open-source Python library used for creating reactive web applications. Dash is a powerful tool for building analytical web applications.
Pros:
- Dash can be used with various domains such as data exploration, data analysis, modeling, visualization, instrument control, and reporting.
- It is very simple to use. It can be installed directly through pip.
- Apart from Python, It can be used with R, Julia, and Jupyter.
- Dash applications are reactive.
- Dash is more customizable than Streamlit. Also, Dash offers better performance.
- Dash has a better, regularly-updated, easy-to-follow documentation.
Cons:
- Dash is more focused on the enterprise market and doesn’t include all of it’s available features in the open source version.
- Dash is more verbose than Streamlit; you have to write more code to create simple web applications compared to other frameworks.
Streamlit
Streamlit is another popular tool that is used to create user interfaces. It is an open-source Python library that is used to build powerful, custom web applications for data science and machine learning. Streamlit is compatible with several major libraries and frameworks such as Latex, OpenCV, Vega-Lite, seaborn, PyTorch, NumPy, Altair, and more.
Like Gradio, Streamlit is also popular and used among big industry leaders, such as Uber and Google X.
Pros:
- Streamlit is accessible for everyone who understands Python. There is no requirement for HTML and CSS.
- It has a wide range of UI components. It covers almost every common UI component such as checkbox, slider, a collapsible sidebar, radio buttons, file upload, progress bar, etc. Moreover, these components are very easy to use.
- It supports multiple interactive visualization libraries such Latex, OpenCV, Vega-Lite, etc.
Cons:
- While not difficult, Streamlit does require some time to learn its own syntax.
- Streamlit is not that flexible. It is only based on Python, offers a limited set of widgets, and doesn’t integrate with Python Notebooks.
- The data upload limit is only 50Mb.
- There is limited support for video/animation.
Conclusion
Apart from these three discussed frameworks, some of these libraries have been around for a while, and some are brand new. Some are more rigid, and have their own structure, while others are flexible and can adapt to yours. Here’s a table showing the tradeoffs among these three: