-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplication.py
75 lines (43 loc) · 1.36 KB
/
application.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
import streamlit as st
import numpy as np
import pandas as pd
import sklearn
import pickle
import xgboost as xgb
import time
from custom_preprocessing import *
from streamlit import caching
st.title('All state claim severity prediction application')
st.markdown("***")
st.image(image = 'allstate_logo.png')
st.subheader('For how many records do you want to predict the claim loss?')
option = st.radio('',('Single claim record', 'Multiple claim records'))
st.write('You selected:', option)
st.subheader('Input a csv file with claim records')
uploaded_file = st.file_uploader(' ')
print(uploaded_file)
predict_button = st.button('Predict the loss ')
if predict_button:
if option == 'Single claim record':
df = pd.read_csv(uploaded_file.name)
with st.spinner('Processing claim'):
loss = final_fun_1(df)
loss_df = pd.DataFrame(loss)
st.success('The predicted loss is ')
loss_df
#st.success('The predicted loss is ' + str(k))
if option == 'Multiple claim records':
df = pd.read_csv(uploaded_file.name)
df
with st.spinner('Processing claim'):
loss = final_fun_1(df)
loss_df = pd.DataFrame(loss)
st.success('The predicted loss is ')
loss_df
st.markdown("***")
#st.write(' Try again with different inputs')
result = st.button(' Try again')
if result:
uploaded_file = st.empty()
predict_button = st.empty()
caching.clear_cache()