Spaces:
Sleeping
Sleeping
import joblib | |
import pandas as pd | |
import streamlit as st | |
model = joblib.load('model (1).joblib') | |
unique_values = joblib.load('unique_values (1).joblib') | |
unique_Married_Single = unique_values["Married/Single"] | |
unique_House_Ownership = unique_values["House_Ownership"] | |
unique_Car_Ownership = unique_values["Car_Ownership"] | |
unique_Profession = unique_values["Profession"] | |
unique_CITY = unique_values["CITY"] | |
unique_STATE = unique_values["STATE"] | |
def main(): | |
st.title("Loan Risk_Flag Analysis") | |
with st.form("questionaire"): | |
Income = st.slider("Income", min_value=10000, max_value=9999999) | |
Age = st.slider("Age", min_value=10, max_value=100) | |
Experience = st.slider("Experience", min_value=0, max_value=20) | |
CURRENT_JOB_YRS = st.slider("CURRENT_JOB_YRS", min_value=0, max_value=14) | |
CURRENT_HOUSE_YRS = st.slider("CURRENT_HOUSE_YRS", min_value=10, max_value=14) | |
Married_Single = st.selectbox("Married/Single", unique_Married_Single) | |
House_Ownership = st.selectbox("House_Ownership", unique_House_Ownership) | |
Car_Ownership = st.selectbox("Car_Ownership", unique_Car_Ownership) | |
Profession = st.selectbox("Profession", unique_Profession) | |
CITY = st.selectbox("CITY", unique_CITY) | |
STATE = st.selectbox("STATE", unique_STATE) | |
clicked = st.form_submit_button("Predict Risk_Flag") | |
if clicked: | |
result=model.predict(pd.DataFrame({"Income": [Income], | |
"Age": [Age], | |
"Experience": [Experience], | |
"CURRENT_JOB_YRS": [CURRENT_JOB_YRS], | |
"CURRENT_HOUSE_YRS": [CURRENT_HOUSE_YRS], | |
"Married_Single": [Married_Single], | |
"House_Ownership": [House_Ownership], | |
"Car_Ownership": [Car_Ownership], | |
"Profession": [Profession], | |
"CITY": [CITY], | |
"STATE": [STATE]})) | |
result = 'none_risk_flag' if result[0] == 1 else 'risk_flag' | |
st.success('The predicted income is {}'.format(result)) | |
if __name__=='__main__': | |
main() |