Voiced by Amazon Polly |
Introduction
Streamlit is a Python-based open-source framework. It enables quick and elegant web app development for machine learning and data science. Major Python libraries are compatible, like scikit-learn, keras, PyTorch, latex, numpy, pandas, matplotlib, etc.
Pioneers in Cloud Consulting & Migration Services
- Reduced infrastructural costs
- Accelerated application deployment
Steps for installation and setting up the Streamlit
Below is the syntax for installing this library.
Open the terminal and type
1 |
pip install streamlit |
Once the library is installed, we can import the streamlit library using the below command.
1 |
import streamlit as stl |
To run the python file, we must run the following command in the terminal.
1 |
streamlit run filename.py |
Some functionalities that can be performed using Streamlit
- Add a title
1 2 3 4 5 6 7 |
#importing the library import streamlit as stl # add title to your app stl.title("CloudThat ") |
- Add a text
1 2 3 4 5 6 7 8 9 10 11 |
#importing the library import streamlit as stl # adding title to your app stl.title("Cloudthat ") #adding text to your app stl.write("CloudThat incepted in 2012 is the first Indian organization to offer Cloud training and consultancy for mid-market and enterprise clients") |
The output will be as follows:
3. Success, Warning, Error, and Info
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
# success st.success("Success") # warning st.warning("Warning") # error st.error("Error") # information st.info("Information") |
Output:
4. Displaying the images
1 2 3 4 5 6 7 8 9 10 11 12 13 |
import streamlit as st # importing Image from pillow library to open images from PIL import Image img = Image.open("cloudthat_logo.png") # displaying image using streamlit # width parameter is used to set the width of an image st.image(img, width=200) |
Output:
5. Checkbox: Returns a Boolean if True or False
1 2 3 4 5 6 7 8 9 |
# check if the checkbox is checked # title of the checkbox should be 'Show/Hide' if st.checkbox("Show/Hide"): # display the text if checkbox returns True as the value st.text("Showing the widget") |
6. Selection box
1 2 3 4 5 6 7 8 9 10 11 |
# first parameter takes the title of the selectionbox # second parameter takes options hobby = st.selectbox("Hobbies: ", ['Dancing', 'Reading', 'Sports']) # print the selected hobby st.write("Your hobby is: ", hobby) |
7. Visualization of histogram
1 2 |
st.write('This is a bar_chart.') st.bar_chart(dataframe) |
Advantages and Disadvantages of the Streamlit:
Advantages:
- One benefit is that it supports Python scripting.
- Amazing web applications can be made with less code.
- Since widgets are viewed as variables, call-backs are not required.
- Data caching makes computation pipelines simpler and faster.
Disadvantage:
One drawback is that Streamlit’s data caching cannot keep track of changes that occur outside the function body.
Python Graphing Libraries Supported
All of the major Python charting libraries are supported by Streamlit, and support for additional libraries is planned for the future. The Pyplot library from Matplotlib, Seaborn, Altair, Vega-Lite, Plotly, Bokeh, PyDeck (which enables 3D and map graphing options), and GraphViz are all currently supported.
Streamlit offers its native graphing library, which includes maps, bar charts, area charts, and line charts. Since they only offer these charts, their native graphing library is not very large. As the framework develops, they intend to increase its graphing possibilities.
Ease of use
The complete Streamlit API can be read in one sitting and is simple. Users may build widgets using only Python, thanks to the API, free from concerns about back-end code, routes, and requests. The simplicity of Streamlit is unquestionably its greatest asset, and the business takes pride in having a “simple” architecture.
Design Flexibility
Features like a sidebar, beta columns, and beta expander provide layout customization. Inputs and widgets can be added to the sidebar to enhance your application’s UI. Beta columns can be used to construct columns in your application so that items can be arranged side by side, while beta expander lets you save space by obscuring text in clickable dropdown menus.
You can construct your own Streamlit Components, giving you more control over the design of your application if you are proficient in HTML and JavaScript. A few highlighted components made by members of the Streamlit community are included in the website’s “Components” section. A few intriguing ones are embedding drawable canvasses into your application and allowing users to remark under your Streamlit application, among many others. The library of user-created components will expand along with the framework’s size and stature, giving you additional control and fine-tuned functionality to employ in your projects.
Conclusion
If you currently have a Python code base and want to turn it into an interactive dashboard as quickly and easily as possible, Streamlit is an excellent framework. Streamlit takes great pride in how simple it is to use, and for a good reason. With Streamlit, there is no learning curve at all, and their API is immediately digestible and usable. The Streamlit Sharing platform is easy to use and a wonderful deployment choice for individuals who do not want to deal with the stress of setting up their servers if they are developing open-source data science applications.
Get your new hires billable within 1-60 days. Experience our Capability Development Framework today.
- Cloud Training
- Customized Training
- Experiential Learning
About CloudThat
CloudThat is also the official AWS (Amazon Web Services) Advanced Consulting Partner and Training partner and Microsoft gold partner, helping people develop knowledge of the cloud and help their businesses aim for higher goals using best in industry cloud computing practices and expertise. We are on a mission to build a robust cloud computing ecosystem by disseminating knowledge on technological intricacies within the cloud space. Our blogs, webinars, case studies, and white papers enable all the stakeholders in the cloud computing sphere.
Drop a query if you have any questions regarding Streamlit and I will get back to you quickly.
To get started, go through our Consultancy page and Managed Services Package that is CloudThat’s offerings.
FAQs
1. What is Streamlit?
ANS: – Streamlit is a Python-based open-source framework. It enables quick and elegant web app development for machine learning and data science.
2. How to install Streamlit?
ANS: –
- Open the terminal and type
- pip install streamlit
WRITTEN BY Vinayak Kalyanshetti
Click to Comment