-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdashboard01.py
109 lines (77 loc) · 2.7 KB
/
dashboard01.py
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
# Core Pkgs
import streamlit as st
# EDA Pkgs
import pandas as pd
import numpy as np
# Data Viz Pkg
import matplotlib.pyplot as plt
import matplotlib
matplotlib.use("Agg")
import seaborn as sns
def main():
"""Semi Automated ML App with Streamlit """
activities = ["EDA","Plots"]
choice = st.sidebar.selectbox("Select Activities",activities)
if choice == 'EDA':
st.subheader("Exploratory Data Analysis")
data = st.file_uploader("Upload a Dataset", type=["csv", "txt"])
if data is not None:
df = pd.read_csv(data)
st.dataframe(df.head())
if st.checkbox("Show Shape"):
st.write(df.shape)
if st.checkbox("Show Columns"):
all_columns = df.columns.to_list()
st.write(all_columns)
if st.checkbox("Summary"):
st.write(df.describe())
if st.checkbox("Show Selected Columns"):
selected_columns = st.multiselect("Select Columns",all_columns)
new_df = df[selected_columns]
st.dataframe(new_df)
if st.checkbox("Show Value Counts"):
st.write(df.iloc[:,-1].value_counts())
if st.checkbox("Correlation Plot(Matplotlib)"):
plt.matshow(df.corr())
st.pyplot()
if st.checkbox("Correlation Plot(Seaborn)"):
st.write(sns.heatmap(df.corr(),annot=True))
st.pyplot()
if st.checkbox("Pie Plot"):
all_columns = df.columns.to_list()
column_to_plot = st.selectbox("Select 1 Column",all_columns)
pie_plot = df[column_to_plot].value_counts().plot.pie(autopct="%1.1f%%")
st.write(pie_plot)
st.pyplot()
elif choice == 'Plots':
st.subheader("Data Visualization")
data = st.file_uploader("Upload a Dataset", type=["csv", "txt", "xlsx"])
if data is not None:
df = pd.read_csv(data)
st.dataframe(df.head())
if st.checkbox("Show Value Counts"):
st.write(df.iloc[:,-1].value_counts().plot(kind='bar'))
st.pyplot()
# Customizable Plot
all_columns_names = df.columns.tolist()
type_of_plot = st.selectbox("Select Type of Plot",["area","bar","line","hist","box","kde"])
selected_columns_names = st.multiselect("Select Columns To Plot",all_columns_names)
if st.button("Generate Plot"):
st.success("Generating Customizable Plot of {} for {}".format(type_of_plot,selected_columns_names))
# Plot By Streamlit
if type_of_plot == 'area':
cust_data = df[selected_columns_names]
st.area_chart(cust_data)
elif type_of_plot == 'bar':
cust_data = df[selected_columns_names]
st.bar_chart(cust_data)
elif type_of_plot == 'line':
cust_data = df[selected_columns_names]
st.line_chart(cust_data)
# Custom Plot
elif type_of_plot:
cust_plot= df[selected_columns_names].plot(kind=type_of_plot)
st.write(cust_plot)
st.pyplot
if __name__ == '__main__':
main()