-
Notifications
You must be signed in to change notification settings - Fork 0
/
SPDashboard.py
87 lines (72 loc) · 4.57 KB
/
SPDashboard.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
import streamlit as st
import pandas as pd
import plotly.graph_objects as go
st.title('Stroke Prediction Dashboard')
st.markdown('The dashboard will help a researcher to get to know more about the given datasets and it’s output')
# Load data
data = pd.read_csv('demo_data_set.csv')
# SideBar Content
st.sidebar.title('Select Visual Charts')
chart_visual = st.sidebar.selectbox('Select Charts/Plot type', ('Line Chart','Bar Chart','Bubble Chart'))
st.sidebar.markdown('Select any of the status accordingly')
check = st.sidebar.radio('Show analysis by...',['Smoking','Blood Pressure','Cholesterol level','Obesity'], index=0)
if check == 'Smoking':
selected_status = st.sidebar.selectbox('Select Smoking Status', options=['Formerly_Smoked', 'Smoked','Never_Smoked', 'Unknown'])
fig = go.Figure()
if chart_visual == 'Line Chart':
if selected_status == 'Formerly_Smoked':
fig.add_trace(go.Scatter(x = data.Country, y = data.formerly_smoked, mode = 'lines', name = 'Formerly_Smoked'))
elif selected_status == 'Smoked':
fig.add_trace(go.Scatter(x=data.Country, y = data.Smokes, mode = 'lines', name = 'Smoked'))
elif selected_status == 'Never_Smoked':
fig.add_trace(go.Scatter(x=data.Country, y = data.Never_Smoked, mode = 'lines', name = 'Never_Smoked'))
else:
fig.add_trace(go.Scatter(x=data.Country, y=data.Unknown, mode='lines', name='Unknown'))
elif chart_visual == 'Bar Chart':
if selected_status == 'Formerly_Smoked':
fig.add_trace(go.Bar(x = data.Country, y = data.formerly_smoked, name = 'Formerly_Smoked'))
elif selected_status == 'Smoked':
fig.add_trace(go.Bar(x=data.Country, y = data.Smokes, name = 'Smoked'))
elif selected_status == 'Never_Smoked':
fig.add_trace(go.Bar(x=data.Country, y = data.Never_Smoked, name = 'Never_Smoked'))
else:
fig.add_trace(go.Bar(x=data.Country, y=data.Unknown, name='Unknown'))
else:
if selected_status == 'Formerly_Smoked':
fig.add_trace(go.Scatter(x = data.Country, y = data.formerly_smoked, mode = 'markers', marker_size=[40, 60, 80, 60, 40, 50], name = 'Formerly_Smoked'))
elif selected_status == 'Smoked':
fig.add_trace(go.Scatter(x=data.Country, y = data.Smokes, mode = 'markers', marker_size=[40, 60, 80, 60, 40, 50], name = 'Smoked'))
elif selected_status == 'Never_Smoked':
fig.add_trace(go.Scatter(x=data.Country, y = data.Never_Smoked, mode = 'markers', marker_size=[40, 60, 80, 60, 40, 50],name = 'Never_Smoked'))
else:
fig.add_trace(go.Scatter(x=data.Country, y=data.Unknown, mode='markers', marker_size=[40, 60, 80, 60, 40, 50], name='Unknown'))
st.plotly_chart(fig, use_container_width=True)
elif check == 'Blood Pressure':
fig = go.Figure()
if chart_visual == 'Line Chart':
fig.add_trace(go.Scatter(x=data.Country, y=data.Blood_Pressure, mode = 'lines', name ='Stroke due to High Blood Pressure'))
elif chart_visual == 'Bar Chart':
fig.add_trace(go.Bar(x=data.Country, y=data.Blood_Pressure, name ='Stroke due to High Blood Pressure'))
else:
fig.add_trace(go.Scatter(x=data.Country, y=data.Blood_Pressure, mode = 'markers', marker_size=[40, 50, 60, 70, 60, 50],name ='Stroke due to High Blood Pressure'))
st.plotly_chart(fig, use_container_width=True)
elif check == 'Cholesterol level':
fig = go.Figure()
if chart_visual == 'Line Chart':
fig.add_trace(go.Scatter(x=data.Country, y=data.Cholesterol, mode = 'lines', name ='Stroke due to High Cholesterol level'))
elif chart_visual == 'Bar Chart':
fig.add_trace(go.Bar(x=data.Country, y=data.Cholesterol, name ='Stroke due to High Cholesterol level'))
else:
fig.add_trace(go.Scatter(x=data.Country, y=data.Cholesterol, mode = 'markers', marker_size=[40, 50, 60, 70, 60, 50],name ='Stroke due to High Cholesterol level'))
st.plotly_chart(fig, use_container_width=True)
elif check == 'Obesity':
fig = go.Figure()
if chart_visual == 'Line Chart':
fig.add_trace(go.Scatter(x=data.Country, y=data.Obesity, mode = 'lines', name ='Stroke due to High Obesity level'))
elif chart_visual == 'Bar Chart':
fig.add_trace(go.Bar(x=data.Country, y=data.Obesity, name ='Stroke due to High Obesity level'))
else:
fig.add_trace(go.Scatter(x=data.Country, y=data.Obesity, mode = 'markers', marker_size=[40, 50, 60, 70, 60, 50],name ='Stroke due to High Obesity level'))
st.plotly_chart(fig, use_container_width=True)
else:
st.warning('Check the required status box for display')