Building An Iris Exploratory Data Analysis App with Streamlit in Python

Streamlit is so cool. After scanning through their documentations and api, as always we will build a simple Exploratory Data Analysis  (EDA) app using streamlit in python. We will be building one for the famous iris dataset. First of all what is streamlit?

Streamlit is a great framework for building ML tools with speed. It is the fastest way to build custom machine learning and data science apps.It comes as a package and a CLI for running your app.

From their official website , it is defined as ‘the first app framework specifically for Machine Learning and Data Science teams

It offers so much benefits and features with clarity. All you need is to import the package and start.

Ok, too much of the talking ,let us explore this framework and then move on to building our EDA app.


pip install streamlit

To explore the CLI, you can fire up your terminal and then type

streamlit  --help

To run your app or python script, all you need is to add the run command to the streamlit and then your app as below

streamlit run

Let us begin with our app. We will create a file called This is where we will write all our code. We do not need a front-end or html file to render the result. Streamlit will take care of that for us.

This is what we will be building

Streaamlit Iris EDA App Python

The main code you need to is to import the streamlit module and wrap them around your python code as below.

import streamlit as st
name = "Iris App"

Then run your script with the CLI as

streamlit run

This will automatically open your default browser with your localhost on mostly port 8501 or any available port. And that is all, you will see the result of your script. Fascinating!

You can make plots, display images,videos,audios, dataframes, tables and many more.

You can check the video below for how each of these are done or their docs.

Building The Iris EDA App

As we have seen how it works, we will move on to building our EDA app. The structure of the app is as follows

  • Preview Our Dataset with df.head() or df.tail()
  • Show Our Columns with df.columns
  • Show the Entire Dataset
  • Select Columns
  • Show Summary of Dataset
  • Make Data Visualizations eg Correlation Plot,Bar Plots,Area Plot,etc
  • Manipulate the Iris Species Images

Below is the code for the entire app


# Import our Pkgs
import streamlit as st
import pandas as pd
import numpy as np
import os
import matplotlib.pyplot as plt
import seaborn as sns
from PIL import Image,ImageFilter,ImageEnhance

# Title and Subheader
st.title("Iris EDA App")
st.subheader("EDA Web App with Streamlit ")

my_dataset = "iris.csv"

# To Improve speed and cache data
def explore_data(dataset):
	df = pd.read_csv(os.path.join(dataset))
	return df 

# Our Dataset
data = explore_data(my_dataset)

# Show Dataset
if st.checkbox("Preview DataFrame"):
	if st.button("Head"):
	if st.button("Tail"):

# Show Entire Dataframe
if st.checkbox("Show All DataFrame"):

# Show Description
if st.checkbox("Show All Column Name"):

# Dimensions
data_dim ='What Dimension Do You Want to Show',('Rows','Columns'))
if data_dim == 'Rows':
	st.text("Showing Length of Rows")
if data_dim == 'Columns':
	st.text("Showing Length of Columns")

if st.checkbox("Show Summary of Dataset"):

# Selection
species_option = st.selectbox('Select Columns',('sepal_length','sepal_width','petal_length','petal_width','species'))
if species_option == 'sepal_length':
elif species_option == 'sepal_width':
elif species_option == 'petal_length':
elif species_option == 'petal_width':
elif species_option == 'species':
	st.write("Select A Column")

# Show Plots
if st.checkbox("Simple Bar Plot with Matplotlib "):

# Show Plots
if st.checkbox("Simple Correlation Plot with Matplotlib "):

# Show Plots
if st.checkbox("Simple Correlation Plot with Seaborn "):
	# Use Matplotlib to render seaborn

# Show Plots
if st.checkbox("Bar Plot of Groups or Counts"):
	v_counts = data.groupby('species')

# Iris Image Manipulation
def load_image(img):
	return im

# Image Type
species_type ='What is the Iris Species do you want to see?',('Setosa','Versicolor','Virginica'))

if species_type == 'Setosa':
	st.text("Showing Setosa Species")
elif species_type == 'Versicolor':
	st.text("Showing Versicolor Species")
elif species_type == 'Virginica':
	st.text("Showing Virginica Species")

# Show Image
if st.checkbox("Show Image/Hide Image"):
	my_image = load_image('iris_setosa.jpg')
	enh = ImageEnhance.Contrast(my_image)
	num = st.slider("Set Your Contrast Number",1.0,3.0)
	img_width = st.slider("Set Image Width",300,500)

# About

if st.button("About App"):
	st.subheader("Iris Dataset EDA App")
	st.text("Built with Streamlit")
	st.text("Thanks to the Streamlit Team Amazing Work")

if st.checkbox("By"):
	st.text("Jesse E.Agbe(JCharis)")
	st.text("Jesus Saves@JCharisTech")


The full code is on github.

You can check  the video for a full walkthrough of the entire tutorial below.

Streamlit is so cool. The Streamlit team has done a great work.

Thanks For Your Time

Jesus Saves

By Jesse E.Agbe(JCharis)

Leave a Comment

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