This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## MAP | |
# Variable for date picker, default to Jan 1st 2020 | |
date = datetime.date(2020,1,1) | |
# Set viewport for the deckgl map | |
view = pdk.ViewState(latitude=0, longitude=0, zoom=0.2,) | |
# Create the scatter plot layer | |
covidLayer = pdk.Layer( | |
"ScatterplotLayer", | |
data=df, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## linechart | |
st.subheader('Comparision of infection growth') | |
total_cases_graph =alt.Chart(subset_data).transform_filter( | |
alt.datum.total_cases > 0 | |
).mark_line().encode( | |
x=alt.X('date', type='nominal', title='Date'), | |
y=alt.Y('sum(total_cases):Q', title='Confirmed cases'), | |
color='Country', | |
tooltip = 'sum(total_cases)', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
filter_data = df[df['Date'] >='2020-04-01'].set_index("Date") | |
st.markdown(str(','.join(country_name_input)) + " daily Death cases from 1st April 2020") | |
# bar chart | |
st.bar_chart(filter_data[['Deaths']]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
metrics =['total_cases','new_cases','total_deaths','new_deaths','total_cases_per_million','new_cases_per_million','total_deaths_per_million','new_deaths_per_million','total_tests','new_tests','total_tests_per_thousand','new_tests_per_thousand'] | |
cols = st.selectbox('Covid metric to view', metrics) | |
# let's ask the user which column should be used as Index | |
if cols in metrics: | |
metric_to_show_in_covid_Layer = cols |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Filters UI | |
subset_data = df | |
country_name_input = st.sidebar.multiselect( | |
'Country name', | |
df.groupby('Country/Region').count().reset_index()['Country/Region'].tolist()) | |
# by country name | |
if len(country_name_input) > 0: | |
subset_data = df[df['Country/Region'].isin(country_name_input)] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DATA_URL = ('covid.csv') | |
@st.cache | |
def load_data(): | |
data = pd.read_csv(DATA_URL) | |
data['Date'] = pd.to_datetime(data['Date']).dt.strftime('%Y-%m-%d') | |
return data | |
df = load_data() | |
# show data on streamlit | |
st.write(df) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import nan | |
words = list(set(data["word"].values)) | |
n_words = len(words) | |
tags = [] | |
for tag in set(data["tag"].values): | |
if tag is nan or isinstance(tag, float): | |
tags.append('unk') | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from math import nan | |
words = list(set(data["word"].values)) | |
n_words = len(words) | |
tags = [] | |
for tag in set(data["tag"].values): | |
if tag is nan or isinstance(tag, float): | |
tags.append('unk') | |
else: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.callbacks import ModelCheckpoint | |
import matplotlib.pyplot as plt | |
#Optimiser | |
adam = k.optimizers.Adam(lr=0.0005, beta_1=0.9, beta_2=0.999) | |
# Compile model | |
model.compile(optimizer=adam, loss=crf.loss_function, metrics=[crf.accuracy, 'accuracy']) | |
model.summary() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from keras.models import Model, Input | |
from keras.layers import LSTM, Embedding, Dense, TimeDistributed, Dropout, Bidirectional | |
import keras as k | |
from keras_contrib.layers import CRF | |
input = Input(shape=(672,)) | |
word_embedding_size = 150 | |
# Embedding Layer | |
model = Embedding(input_dim=n_words, output_dim=word_embedding_size, input_length=672)(input) |
NewerOlder