custumer_risk_credit / app (1).py
pepperjirakit's picture
Upload app (1).py
62c442e
raw
history blame
1.94 kB
from ssl import Options
import joblib
import pandas as pd
import streamlit as st
model = joblib.load('model.joblib')
unique_values = joblib.load('unique_values(1).joblib')
#unique_post_on = unique_values["Posted On"]
unique_fea_1 = unique_values["fea_1"]
unique_fea_2 = unique_values["fea_2"]
unique_fea_3 = unique_values["fea_3"]
unique_fea_4 = unique_values["fea_4"]
unique_fea_5 = unique_values["fea_5"]
unique_fea_6 = unique_values["fea_6"]
unique_fea_7 = unique_values["fea_7"]
unique_fea_8 = unique_values["fea_8"]
unique_fea_9 = unique_values["fea_9"]
unique_fea_10 = unique_values["fea_10"]
unique_fea_11 = unique_values["fea_11"]
def main():
st.title("Customer check risk")
with st.form("questionaire"):
fea1 = st.selectbox(options =unique_fea_1 )
fea3 = st.selectbox(options =unique_fea_3)
fea5 = st.selectbox(options =unique_fea_5 )
fea6 = st.selectbox(options =unique_fea_6 )
fea7 = st.selectbox(options =unique_fea_7 )
fea9 = st.selectbox(options =unique_fea_9 )
# clicked==True only when the button is clicked
clicked = st.form_submit_button("risk")
if clicked:
result=model.predict(pd.DataFrame({"fea1": [fea1],
"fea3": [fea3],
"fea5": [fea5],
"fea6": [fea6],
"fea7": [fea7],
"fea9": [fea9]
}))
# Show prediction
if result==1:
result='the customer is in high credit risk'
else :
result='the customer is in low credit risk'
st.success('Your risk is '+result)
# Run main()
if __name__=='__main__':
main()