Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import pickle
|
3 |
+
import numpy as np
|
4 |
+
|
5 |
+
# Load your saved model
|
6 |
+
with open('xgb_credit_score_model.pkl', 'rb') as file:
|
7 |
+
model = pickle.load(file)
|
8 |
+
|
9 |
+
# Define the prediction function
|
10 |
+
def predict_credit_score(interest_rate, num_credit_inquiries, delay_from_due_date,
|
11 |
+
num_credit_card, num_bank_accounts, outstanding_debt,
|
12 |
+
num_of_delayed_payment, num_of_loan):
|
13 |
+
# Arrange inputs into a format that the model expects
|
14 |
+
features = np.array([[interest_rate, num_credit_inquiries, delay_from_due_date,
|
15 |
+
num_credit_card, num_bank_accounts, outstanding_debt,
|
16 |
+
num_of_delayed_payment, num_of_loan]])
|
17 |
+
prediction = model.predict(features)
|
18 |
+
return f"Predicted Credit Score Category: {int(prediction[0])}"
|
19 |
+
|
20 |
+
# Set up Gradio input interface with labeled inputs
|
21 |
+
inputs = [
|
22 |
+
gr.Number(label="Interest Rate"),
|
23 |
+
gr.Number(label="Number of Credit Inquiries"),
|
24 |
+
gr.Number(label="Days Delayed from Due Date"),
|
25 |
+
gr.Number(label="Number of Credit Cards"),
|
26 |
+
gr.Number(label="Number of Bank Accounts"),
|
27 |
+
gr.Number(label="Outstanding Debt"),
|
28 |
+
gr.Number(label="Number of Delayed Payments"),
|
29 |
+
gr.Number(label="Number of Loans")
|
30 |
+
]
|
31 |
+
|
32 |
+
# Define the Gradio interface
|
33 |
+
gr.Interface(fn=predict_credit_score, inputs=inputs, outputs="text",
|
34 |
+
title="Credit Score Predictor",
|
35 |
+
description="Enter your details to get a prediction of your credit score category.")\
|
36 |
+
.launch()
|