Spaces:
Runtime error
Runtime error
File size: 3,289 Bytes
eee56fe adc8a8a eee56fe adc8a8a eee56fe 1389a2a adc8a8a eee56fe adc8a8a eee56fe adc8a8a eee56fe adc8a8a eee56fe adc8a8a 06af648 adc8a8a eee56fe adc8a8a eee56fe 67fa76f adc8a8a eee56fe adc8a8a e7f00e2 adc8a8a eee56fe 88ad1fe 1980429 eee56fe a8701c9 ebbe50b |
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 |
import joblib
import pandas as pd
import streamlit as st
EDU_DICT = {'unknown': 1,
'secondary': 2,
'primary': 3,
'tertiary': 4,
}
model = joblib.load('model.joblib')
unique_values = joblib.load('unique_values.joblib')
unique_job = unique_values["job"]
unique_marital = unique_values["marital"]
unique_default = unique_values["default"]
unique_housing = unique_values["housing"]
unique_loan = unique_values["loan"]
unique_contact = unique_values["contact"]
unique_month = unique_values["month"]
unique_poutcome = unique_values["poutcome"]
unique_education = unique_values["education"]
def main():
st.title("Bank Marketing")
with st.form("questionaire"):
age = st.slider("Age", min_value=15, max_value=100)
job = st.selectbox("Job", options = unique_job)
marital = st.selectbox("Marital", options = unique_marital)
education = st.selectbox("Education", options = unique_education)
default = st.selectbox("Default", options = unique_default)
balance = st.slider("Balance", min_value=-9000, max_value=200000)
housing = st.selectbox("Housing", options = unique_housing)
loan = st.selectbox("Loan", options = unique_loan)
contact = st.selectbox("Contact", options = unique_contact)
day = st.slider("Day", min_value=1, max_value=50)
month = st.selectbox("Month", options = unique_month)
duration = st.slider("Duration", min_value=0, max_value=5000)
campaign = st.slider("Campaign", min_value=1, max_value=100)
pdays = st.slider("Pdays", min_value=-10, max_value=1000)
previous = st.slider("Previous", min_value=0, max_value=300)
poutcome = st.selectbox("Poutcome", options = unique_poutcome)
# clicked==True only when the button is clicked
clicked = st.form_submit_button("Predict y")
if clicked:
result=model.predict(pd.DataFrame({"age": [age],
"job": [job],
"marital": [marital],
"education": [EDU_DICT[education]],
"default": [default],
"balance": [balance],
"housing": [housing],
"loan": [loan],
"contact": [contact],
"day": [day],
"month": [month],
"duration": [duration],
"campaign": [campaign],
"pdays": [pdays],
"previous": [previous],
"poutcome": [poutcome]}))
# Show prediction
result = 'yes' if result[0] == 1 else 'no'
st.success("Your predicted y is "+result) #แสดงผล
# Run main()
if __name__ == "__main__":
main() |