-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
146 lines (115 loc) · 3.55 KB
/
app.py
File metadata and controls
146 lines (115 loc) · 3.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
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 ")
# EDA
my_dataset = "iris.csv"
# To Improve speed and cache data
@st.cache(persist=True)
def explore_data(dataset):
df = pd.read_csv(os.path.join(dataset))
return df
# Show Dataset
if st.checkbox("Preview DataFrame"):
data = explore_data(my_dataset)
if st.button("Head"):
st.write(data.head())
if st.button("Tail"):
st.write(data.tail())
else:
st.write(data.head(2))
# Show Entire Dataframe
if st.checkbox("Show All DataFrame"):
data = explore_data(my_dataset)
st.dataframe(data)
# Show Description
if st.checkbox("Show All Column Name"):
data = explore_data(my_dataset)
st.text("Columns:")
st.write(data.columns)
# Dimensions
data_dim = st.radio('What Dimension Do You Want to Show',('Rows','Columns'))
if data_dim == 'Rows':
data = explore_data(my_dataset)
st.text("Showing Length of Rows")
st.write(len(data))
if data_dim == 'Columns':
data = explore_data(my_dataset)
st.text("Showing Length of Columns")
st.write(data.shape[1])
if st.checkbox("Show Summary of Dataset"):
data = explore_data(my_dataset)
st.write(data.describe())
# Selection
species_option = st.selectbox('Select Columns',('sepal_length','sepal_width','petal_length','petal_width','species'))
data = explore_data(my_dataset)
if species_option == 'sepal_length':
st.write(data['sepal_length'])
elif species_option == 'sepal_width':
st.write(data['sepal_width'])
elif species_option == 'petal_length':
st.write(data['petal_length'])
elif species_option == 'petal_width':
st.write(data['petal_width'])
elif species_option == 'species':
st.write(data['species'])
else:
st.write("Select A Column")
# Show Plots
if st.checkbox("Simple Bar Plot with Matplotlib "):
data = explore_data(my_dataset)
data.plot(kind='bar')
st.pyplot()
# Show Plots
if st.checkbox("Simple Correlation Plot with Matplotlib "):
data = explore_data(my_dataset)
plt.matshow(data.corr())
st.pyplot()
# Show Plots
if st.checkbox("Simple Correlation Plot with Seaborn "):
data = explore_data(my_dataset)
st.write(sns.heatmap(data.corr(),annot=True))
# Use Matplotlib to render seaborn
st.pyplot()
# Show Plots
if st.checkbox("Bar Plot of Groups or Counts"):
data = explore_data(my_dataset)
v_counts = data.groupby('species')
st.bar_chart(v_counts)
# Iris Image Manipulation
@st.cache
def load_image(img):
im =Image.open(os.path.join(img))
return im
# Image Type
species_type = st.radio('What is the Iris Species do you want to see?',('Setosa','Versicolor','Virginica'))
if species_type == 'Setosa':
st.text("Showing Setosa Species")
st.image(load_image('imgs/iris_setosa.jpg'))
elif species_type == 'Versicolor':
st.text("Showing Versicolor Species")
st.image(load_image('imgs/iris_versicolor.jpg'))
elif species_type == 'Virginica':
st.text("Showing Virginica Species")
st.image(load_image('imgs/iris_virginica.jpg'))
# 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)
st.image(enh.enhance(num),width=img_width)
# 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")