# PREMIUM BANK PORTAL STREAMLIT APP import streamlit as st import pandas as pd import pickle # 1️ App Config st.set_page_config( page_title="Loan Prediction System", layout="wide", page_icon="🏦" ) # 2️ THEME SETTINGS (Edit only this section to change UI) PRIMARY_GRADIENT = "linear-gradient(90deg, #6A82FB, #FC5C7D)" PRIMARY_COLOR = "#6A82FB" SECONDARY_COLOR = "#FC5C7D" TEXT_DARK = "#2C2C2C" CARD_BG = "#FFFFFF" PAGE_BG = "#F4F7FB" FONT = "'Segoe UI', sans-serif" APP_TITLE = "🏦 Premium Loan Status Predictor" FOOTER_TEXT = "Developed with ❤️ by Deepraj | Powered by Streamlit" # 3️ Inject Premium CSS custom_css = f""" """ st.markdown(custom_css, unsafe_allow_html=True) # 4️ Load ML Artifacts model = pickle.load(open("model.pkl", "rb")) scaler = pickle.load(open("scaler.pkl", "rb")) label_encoders = pickle.load(open("label_encoders.pkl", "rb")) cat_cols = pickle.load(open("cat_cols.pkl", "rb")) num_cols = pickle.load(open("num_cols.pkl", "rb")) feature_order = pickle.load(open("feature_order.pkl", "rb")) # 5️ Header st.markdown(f"
{APP_TITLE}
", unsafe_allow_html=True) st.write("### Fill customer details below to predict loan status.") # 6️ Input Section col1, col2 = st.columns(2) user_inputs = {} # --------- Categorical Inputs ---------- with col1: st.markdown("
", unsafe_allow_html=True) st.markdown("
Categorical Details
", unsafe_allow_html=True) for col in cat_cols: user_inputs[col] = st.selectbox( col.replace("_", " ").title(), label_encoders[col].classes_ ) st.markdown("
", unsafe_allow_html=True) # --------- Numerical Inputs ---------- with col2: st.markdown("
", unsafe_allow_html=True) st.markdown("
Numerical Details
", unsafe_allow_html=True) for col in num_cols: user_inputs[col] = st.number_input( col.replace("_", " ").title(), min_value=0.0, step=1.0 ) st.markdown("
", unsafe_allow_html=True) # Convert input → DataFrame df_input = pd.DataFrame([user_inputs]) # 7️ Pre-processing for col in cat_cols: df_input[col] = label_encoders[col].transform(df_input[col]) df_input[num_cols] = scaler.transform(df_input[num_cols]) df_input = df_input.reindex(columns=feature_order) # 8️ Prediction Button st.markdown("
", unsafe_allow_html=True) if st.button("🔍 Predict Loan Status", key="predict", help="Click to check eligibility"): prediction = model.predict(df_input)[0] st.markdown("
", unsafe_allow_html=True) if prediction == "Approved": st.markdown("
Loan Approved!
", unsafe_allow_html=True) else: st.markdown("
Loan Rejected!
", unsafe_allow_html=True)