Spaces:
Sleeping
Sleeping
Upload app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
import requests
|
| 3 |
+
from PIL import Image
|
| 4 |
+
|
| 5 |
+
image = Image.open('dataset-cover.jpg')
|
| 6 |
+
st.title("Aplikasi Car Insurance")
|
| 7 |
+
st.image(image)
|
| 8 |
+
education_format = {0:"None",1:"High School",2:"University"}
|
| 9 |
+
def ed_format(option):
|
| 10 |
+
return education_format[option]
|
| 11 |
+
|
| 12 |
+
income_format = {0:"Poverty",1:"Working Class",2:"Middle Class",3:"Upper Class"}
|
| 13 |
+
def in_format(option):
|
| 14 |
+
return income_format[option]
|
| 15 |
+
EDUCATION = st.selectbox("EDUCATION", options=list(education_format.keys()),format_func=ed_format)
|
| 16 |
+
INCOME = st.selectbox("INCOME", options=list(income_format.keys()),format_func=in_format)
|
| 17 |
+
CREDIT_SCORE = st.number_input("CREDIT_SCORE", min_value=0.00,max_value=0.99)
|
| 18 |
+
ANNUAL_MILEAGE = st.number_input("ANNUAL_MILEAGE", min_value=2000,max_value=22000)
|
| 19 |
+
SPEEDING_VIOLATIONS = st.number_input("SPEEDING_VIOLATIONS",min_value=0,max_value=22)
|
| 20 |
+
PAST_ACCIDENTS = st.number_input("PAST_ACCIDENTS",min_value=0,max_value=15)
|
| 21 |
+
DRIVING_EXPERIENCE = st.selectbox("DRIVING_EXPERIENCE", ['Newbie', 'Amateur', 'Advanced', 'Expert'])
|
| 22 |
+
VEHICLE_OWNERSHIP = st.selectbox("VEHICLE_OWNERSHIP", ['Yes', 'No'])
|
| 23 |
+
MARRIED = st.selectbox("MARRIED", ['Yes', 'No'])
|
| 24 |
+
CHILDREN = st.selectbox("CHILDREN", ['Yes', 'No'])
|
| 25 |
+
# inference
|
| 26 |
+
data = {'EDUCATION':EDUCATION,
|
| 27 |
+
'INCOME':INCOME,
|
| 28 |
+
'CREDIT_SCORE': CREDIT_SCORE,
|
| 29 |
+
'ANNUAL_MILEAGE':ANNUAL_MILEAGE,
|
| 30 |
+
'SPEEDING_VIOLATIONS':SPEEDING_VIOLATIONS,
|
| 31 |
+
'PAST_ACCIDENTS':PAST_ACCIDENTS,
|
| 32 |
+
'DRIVING_EXPERIENCE' : DRIVING_EXPERIENCE,
|
| 33 |
+
'VEHICLE_OWNERSHIP' : VEHICLE_OWNERSHIP,
|
| 34 |
+
'MARRIED' : MARRIED,
|
| 35 |
+
'CHILDREN' : CHILDREN}
|
| 36 |
+
|
| 37 |
+
URL = "https://andreean-backend-car-insurance.hf.space/"
|
| 38 |
+
|
| 39 |
+
# komunikasi
|
| 40 |
+
if st.button('Predict'):
|
| 41 |
+
r = requests.post(URL, json=data)
|
| 42 |
+
res = r.json()
|
| 43 |
+
if res['code'] == 200:
|
| 44 |
+
st.title(res['result']['classes'])
|