loaning / app.py
Uwaish's picture
Update app.py
83ebc04 verified
#!/usr/bin/env python
# coding: utf-8
import gradio as gr
from joblib import load
# Load your trained model
model = load("model_joblib")
# Prediction logic
def predict_loan(Age, Experience, Income, Family, CCAvg, Education, Mortgage,
SecuritiesAccount, CDAccount, Online, CreditCard):
input_data = [[Age, Experience, Income, Family, CCAvg, Education, Mortgage,
SecuritiesAccount, CDAccount, Online, CreditCard]]
prediction = model.predict(input_data)[0]
result = "βœ… Yes - Will Accept Loan" if prediction == 1 else "❌ No - Will Not Accept Loan"
return result
# Gradio Interface
iface = gr.Interface(
fn=predict_loan,
inputs=[
gr.Number(label="Age"),
gr.Number(label="Experience (years)"),
gr.Number(label="Income (in $000)"),
gr.Number(label="Family Members"),
gr.Number(label="CC Average Balance (in $000)"),
gr.Number(label="Education Level (1=Undergrad, 2=Graduate, 3=Advanced)"),
gr.Number(label="Mortgage (in $000)"),
gr.Number(label="Securities Account (1=Yes, 0=No)"),
gr.Number(label="CD Account (1=Yes, 0=No)"),
gr.Number(label="Online Banking (1=Yes, 0=No)"),
gr.Number(label="Credit Card (1=Yes, 0=No)")
],
outputs="text",
title="πŸ“Š Personal Loan Offer Prediction",
description="Enter customer details to predict if they will accept the personal loan offer."
)
if __name__ == "__main__":
print("βœ… App starting... waiting for Gradio interface")
iface.launch(server_name="0.0.0.0", server_port=7860)