-
Notifications
You must be signed in to change notification settings - Fork 0
/
dashboard_assignment.py
139 lines (102 loc) · 5.01 KB
/
dashboard_assignment.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
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
####Import packages
import streamlit as st
import pandas as pd
import numpy as np
from sklearn.ensemble import RandomForestRegressor
from sklearn.metrics import mean_absolute_error
header = st.container()
dataset =st.container()
features = st.container()
model_training = st.container()
with header:
st.title('Welcome to streamlit assignment')
st.text('Unfortunate data posted by HHS about layoffs')
def get_data(hhs_data):
hhs_data = hhs_data = pd.read_csv('https://healthdata.gov/resource/nqtp-eetp.csv')
return hhs_data
#DATA_URL = 'https://healthdata.gov/resource/nqtp-eetp.csv'
with dataset:
st.header('FY 2023 HHS Contingency Staffing Plan for a Lapse in Appropriation')
st.text('HHS’ contingency plans for agency operations in the absence of appropriations ')
hhs_data = pd.read_csv('https://healthdata.gov/resource/nqtp-eetp.csv')
hhs_data = hhs_data.rename(columns={'staff_involved':'Staff Involved','cdc':'Centers for Disease Control and Prevention','cms': 'Centers for Medicare and Medicaid Services', 'fda': 'Food and Drug Administration'})
#hhs_data = hhs_data[['staff_involved','cdc','cms',]]
#st.dataframe(data = hhs_data, x="staff_involved", y="cdc","cms","fda")
st.bar_chart(data = hhs_data, x="Staff Involved", y=("Centers for Disease Control and Prevention","Centers for Medicare and Medicaid Services","Food and Drug Administration"))
#st.table(hhs_data)
st.subheader('CDC staff layoff')
cdc = pd.DataFrame(hhs_data['Staff Involved'], hhs_data['Centers for Disease Control and Prevention'].head())
st.bar_chart(cdc)
# with model_training:
# st.header('Model is trained here')
# st.text('Chose the parameters that you wannna run')
# sel_col, disp_col = st.columns(2)
# max_depth = sel_col.slider('what should be the max depth of the model', min_value=10, max_value=100, value=20, step=10)
# n_estimators = sel_col.selectbox('How many trees should there be', options=[100,200,300,'No limit'], index = 0)
# sel_col.text('Here is a list of features in my data')
# sel_col.write(hhs_data.columns)
# input_feature = sel_col.text_input('Which feature should be used as import feature', 'Centers for Disease Control and Prevention')
# if n_estimators == 'No limit':
# regr = RandomForestRegressor(max_depth=max_depth)
# else:
# regr = RandomForestRegressor(max_depth=max_depth, n_estimators=n_estimators)
# #regr = RandomForestRegressor(max_depth=max_depth, n_estimators=number_of_trees)
# X = hhs_data[[input_feature]]
# y = hhs_data[['Centers for Disease Control and Prevention']]
# regr.fit(X, y)
# prediction = regr.predict(y)
# display_col.subheader('Mean absolute error:')
# display_col.write(mean_absolute_error(y, prediction))
# display_col.subheader('Mean absolute error:')
# display_col.write(mean_absolute_error(y, prediction))
# display_col.subheader('Mean square error:')
# display_col.write(mean_square_error(y, prediction))
# display_col.subheader('R squared error error:')
# display_col.write(r2_score(y, prediction))
#def load_data():
#data = pd.read_csv(DATA_URL)
#lowercase = lambda x: str(x).lower()
#data.rename(lowercase, axis='columns', inplace=True)
#data[DATE_COLUMN] = pd.to_datetime(data[DATE_COLUMN])
#return data
#df = load_data()
#df = df.reset_index()
#df
##check pandas pivot function
# Import packages
# import streamlit as st
# import pandas as pd
# import numpy as np
# from sklearn.ensemble import RandomForestRegressor
# from sklearn.metrics import mean_absolute_error
# header = st.container()
# dataset =st.container()
# features = st.container()
# model_training = st.container()
# with header:
# st.title('Welcome to streamlit assignment')
# st.text('Unfortunate data posted by HHS about layoffs')
# DATA_URL = 'https://healthdata.gov/resource/nqtp-eetp.csv'
# with dataset:
# st.header('FY 2023 HHS Contingency Staffing Plan for a Lapse in Appropriation')
# st.text('HHS’ contingency plans for agency operations in the absence of appropriations ')
# hhs_data = pd.read_csv('https://healthdata.gov/resource/nqtp-eetp.csv')
# hhs_data = hhs_data[['staff_involved','cdc','cms','fda']]
# st.dataframe(hhs_data)
# st.dataframe(data = hhs_data, x=['staff_involved'], y=['cdc','cms','fda'])
# st.bar_chart(data = hhs_data, x=("staff_involved"), y=("cdc","cms","fda"))
# st.table(hhs_data)
# st.subheader('Pickup Location ID distribution')
# pulocation_dist = pd.DataFrame(taxi_data['PULocationID'].value_counts().head(50))
# st.bar_chart(pulocation_dist)
# def load_data():
# data = pd.read_csv('https://healthdata.gov/resource/nqtp-eetp.csv')
# selected_indices = st.multiselect('Select rows:', data.index)
# lowercase = lambda x: str(x).lower()
# data.rename(lowercase, axis='columns', inplace=True)
# data[DATE_COLUMN] = pd.to_datetime(data[DATE_COLUMN])
# return data
# df = load_data()
# df = df.reset_index()
# df
# check pandas pivot function