|
|
import gradio as gr |
|
|
import pandas as pd |
|
|
import numpy as np |
|
|
from joblib import load |
|
|
|
|
|
|
|
|
model = load("credit_classifier.joblib") |
|
|
|
|
|
|
|
|
def predict_credit_score(outstanding_debt, credit_mix, credit_history_age, monthly_balance, |
|
|
payment_behaviour, annual_income, delayed_payments): |
|
|
input_data = [[ |
|
|
outstanding_debt, credit_mix, credit_history_age, |
|
|
monthly_balance, payment_behaviour, annual_income, |
|
|
delayed_payments |
|
|
]] |
|
|
prediction = model.predict(input_data)[0] |
|
|
|
|
|
target_names = {0: "Good", 1: "Poor", 2: "Standard"} |
|
|
return target_names.get(prediction, "Unknown") |
|
|
|
|
|
|
|
|
demo = gr.Interface( |
|
|
fn=predict_credit_score, |
|
|
inputs=[ |
|
|
gr.Number(label="Outstanding Debt"), |
|
|
gr.Number(label="Credit Mix"), |
|
|
gr.Number(label="Credit History Age"), |
|
|
gr.Number(label="Monthly Balance"), |
|
|
gr.Number(label="Payment Behaviour"), |
|
|
gr.Number(label="Annual Income"), |
|
|
gr.Number(label="Delayed Payments"), |
|
|
], |
|
|
outputs="text", |
|
|
title="Credit Scoring Classifier", |
|
|
description="Enter your credit-related information to classify your credit score as Good, Standard, or Poor.", |
|
|
) |
|
|
|
|
|
demo.launch() |
|
|
|