Loan_Prediction / src /streamlit_app.py
3v324v23's picture
build
a84a40a
Raw
History Blame Contribute Delete
2.13 kB
import streamlit as st
import numpy as np
import joblib
model = joblib.load("src/model.pkl")
st.set_page_config(
page_icon= "💵",
page_title= "Check loan Status",
layout= "wide",
menu_items={
'About': "faizwajidkhatri@gmail.com Data Science student"
}
)
st.title("Loan Status Checker")
st.write("Please enter the details of the applicant:")
person_age=st.slider("Age of the applicant", min_value=18, max_value=100, step=1)
person_gender=st.selectbox("Gender of the applicant", options=[0, 1])
person_eduation=st.selectbox("Highest education level", options=[0, 1, 2, 3, 4, 5])
person_income=st.number_input("Annual income of the applicant", min_value=1000, max_value=1000000, step=1000)
person_emp_exp=st.number_input("Years of employment experience", min_value=0, max_value=50, step=1)
person_home_ownership=st.selectbox("Type of home ownership", options=[0, 1, 2, 3])
loan_amnt=st.number_input("Loan amount requested", min_value=1000, max_value=500000, step=1000)
loan_intent=st.selectbox("Purpose of the loan", options=[0, 1, 2, 3, 4, 5])
loan_int_rate=st.number_input("Interest rate on the loan (%)", min_value=0.0, max_value=100.0, step=0.1)
loan_percent_income=st.number_input("Loan amount as a percentage of income", min_value=0.0, max_value=100.0, step=0.1)
cb_person_cred_hist_length=st.slider("Credit history length (in years)", min_value=0, max_value=50, step=1)
credit_score=st.slider("Credit score", min_value=300, max_value=850, step=1)
previous_loan_defaults_on_file=st.selectbox("Previous loan defaults on file", options=[0, 1])
if st.button("Predict Loan Approval"):
input = np.array([[
person_age,
person_gender,
person_eduation,
person_income,
person_emp_exp,
person_home_ownership,
loan_amnt,
loan_intent,
loan_int_rate,
loan_percent_income,
cb_person_cred_hist_length,
credit_score,
previous_loan_defaults_on_file
]])
prediction = model.predict(input)[0]
result = 'approved' if prediction == 1 else 'rejected'
st.success(f"Predicted status: {result}")