import streamlit as st
import pandas as pd
import joblib
def run():
st.markdown("
Welcome to the Credit Default Prediction Model
", unsafe_allow_html=True)
st.markdown("========================================================================================")
st.markdown("User Input Features
", unsafe_allow_html=True)
def user_input():
limit_balance = st.number_input('limit balance', min_value=10000, max_value=100000000, step=10000)
col1,col2= st.columns(2)
pay_1 = col1.slider('pay in september', min_value=-12, max_value=12, format="paid %d month")
pay_2 = col2.slider('pay in august', min_value=-12, max_value=12, format="paid %d month")
pay_3 = col1.slider('pay in july', min_value=-12, max_value=12, format="paid %d month")
pay_4 = col2.slider('pay in june', min_value=-12, max_value=12, format="paid %d month")
pay_5 = col1.slider('pay in may', min_value=-12, max_value=12, format="paid %d month")
pay_6 = col2.slider('pay in april', min_value=-12, max_value=12, format="paid %d month")
data = {
'limit_balance': limit_balance,
'pay_0': pay_1,
'pay_2': pay_2,
'pay_3': pay_3,
'pay_4': pay_4,
'pay_5': pay_5,
'pay_6': pay_6
}
features = pd.DataFrame(data, index=[0])
return features
input = user_input()
st.markdown("User Input Result
", unsafe_allow_html=True)
st.table(input)
load_model = joblib.load("my_model.pkl")
if st.button("Predict", help='Click me!' ):
prediction = load_model.predict(input)
if prediction == 1:
prediction = 'Defaulted Payment'
else:
prediction = 'Not Defaulted'
st.markdown("Based on user input, the default model is predicted:
", unsafe_allow_html=True)
st.markdown(f"{prediction}
", unsafe_allow_html=True)