Spaces:
Running
Running
import gradio as gr | |
import pickle | |
import numpy as np | |
# Load your saved model | |
with open('xgb_credit_score_model.pkl', 'rb') as file: | |
model = pickle.load(file) | |
# Define the prediction function | |
def predict_credit_score(interest_rate, num_credit_inquiries, delay_from_due_date, | |
num_credit_card, num_bank_accounts, outstanding_debt, | |
num_of_delayed_payment, num_of_loan): | |
# Arrange inputs into a format that the model expects | |
features = np.array([[interest_rate, num_credit_inquiries, delay_from_due_date, | |
num_credit_card, num_bank_accounts, outstanding_debt, | |
num_of_delayed_payment, num_of_loan]]) | |
prediction = model.predict(features) | |
return f"Predicted Credit Score Category: {int(prediction[0])}" | |
# Set up Gradio input interface with labeled inputs | |
inputs = [ | |
gr.Number(label="Interest Rate"), | |
gr.Number(label="Number of Credit Inquiries"), | |
gr.Number(label="Days Delayed from Due Date"), | |
gr.Number(label="Number of Credit Cards"), | |
gr.Number(label="Number of Bank Accounts"), | |
gr.Number(label="Outstanding Debt"), | |
gr.Number(label="Number of Delayed Payments"), | |
gr.Number(label="Number of Loans") | |
] | |
# Define the Gradio interface | |
gr.Interface(fn=predict_credit_score, inputs=inputs, outputs="text", | |
title="Credit Score Predictor", | |
description="Enter your details to get a prediction of your credit score category.")\ | |
.launch() | |