| |
| |
|
|
| import gradio as gr |
| from joblib import load |
|
|
| |
| model = load("model_joblib") |
|
|
| |
| 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 |
|
|
| |
| 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) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|