File size: 1,512 Bytes
058e669
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
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()