File size: 1,801 Bytes
058e669
 
 
9a3f13b
 
 
058e669
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
326394b
058e669
326394b
 
 
 
 
 
 
 
058e669
 
d57080c
 
 
 
 
 
 
 
 
 
058e669
 
 
9a3f13b
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
38
39
40
41
42
43
44
45
46
47
48
import gradio as gr
import pickle
import numpy as np
import warnings

warnings.filterwarnings("ignore", category=UserWarning, message="If you are loading a serialized model")

# 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])}"

# Define the 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 a detailed description with the correct category explanation
description = """
Enter your details to get a prediction of your credit score category.

**Credit Score Categories**:
- 2 = Good
- 1 = Standard
- 0 = Poor
"""

# Define the Gradio interface
gr.Interface(fn=predict_credit_score, inputs=inputs, outputs="text",
             title="Credit Score Predictor",
             description=description).launch()