Spaces:
Build error
Build error
File size: 5,428 Bytes
33dc257 |
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 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
import joblib
model = joblib.load("xgb.pkl")
def predict(*args):
input_data = []
for i in args:
input_data.append(float(i))
input_data = np.asarray(input_data)
# reshape the array as we are predicting for one instance
input_data_reshaped = input_data.reshape(1, -1)
prediction = model.predict(input_data_reshaped)
if prediction[0] == 0:
return "The Credit Score is Good"
elif prediction[0] == 1:
return "The Credit Score is Poor"
else:
return "The Credit Score is Standard"
with gr.Blocks() as app:
gr.Markdown(
"""
**Credit Score Classification**"""
)
with gr.Row():
with gr.Column():
Annual_Income = gr.TextArea(label="Annual Income")
Monthly_Inhand_Salary = gr.TextArea(label="Monthly Inhand Salary")
Interest_Rate = gr.TextArea(label="Interest Rate")
Num_of_Loan = gr.Slider(
label="Number of Loans", minimum=1, maximum=10, step=1, randomize=True
)
Delay_from_due_date = gr.Slider(
label="Number of Delayed Days",
minimum=-100,
maximum=100,
step=1,
randomize=True,
)
Num_of_Delayed_Payment = gr.Slider(
label="Number of Delayed Payments",
minimum=1,
maximum=10,
step=1,
randomize=True,
)
Credit_Mix = gr.Dropdown(
label="Credit Mix (Bad: 0, Don't Have: 1, Good: 2, Standard: 3)",
choices=[0,1,2,3],
value=lambda: random.choice([0,1,2,3]),
)
Outstanding_Debt = gr.TextArea(label="Outstanding Debt")
Credit_Utilization_Ratio = gr.TextArea(label="Credit Utilization Ratio")
Payment_of_Min_Amount = gr.Dropdown(
label="Payment of Minimum Amount (NM: 0, No: 1, Yes: 2)",
choices=[0,1,2],
value=lambda: random.choice([0,1,2]),
)
Total_EMI_per_month = gr.TextArea(label="Total Equated Monthly Installment")
Amount_invested_monthly = gr.TextArea(label="Amount Invested Monthly")
Monthly_Balance = gr.TextArea(label="Monthly Balance")
Credit_History_Age_In_Years = gr.TextArea(label="Credit History in Years")
StudentLoan = gr.Dropdown(
label="Student Loan (Don't Have: 0, Have: 1)",
choices=[0,1],
value=lambda: random.choice([0,1]),
)
MortgageLoan= gr.Dropdown(
label="Mortage Loan (Don't Have: 0, Have: 1)",
choices=[0,1],
value=lambda: random.choice([0,1]),
)
PersonalLoan = gr.Dropdown(
label="Personal Loan (Don't Have: 0, Have: 1)",
choices=[0,1],
value=lambda: random.choice([0,1]),
)
DebtConsolidationLoan = gr.Dropdown(
label="Debt Consolidation Loan (Don't Have: 0, Have: 1)",
choices=[0,1],
value=lambda: random.choice([0,1]),
)
Credit_BuilderLoan = gr.Dropdown(
label="Credit Builder Loan (Don't Have: 0, Have: 1)",
choices=[0,1],
value=lambda: random.choice([0,1]),
)
HomeEquityLoan = gr.Dropdown(
label="Home Equity Loan (Don't Have: 0, Have: 1)",
choices=[0,1],
value=lambda: random.choice([0,1]),
)
NotSpecified = gr.Dropdown(
label="Unspecified Loan (Don't Have: 0, Have: 1)",
choices=[0,1],
value=lambda: random.choice([0,1]),
)
AutoLoan = gr.Dropdown(
label="Auto Loan (Don't Have: 0, Have: 1)",
choices=[0,1],
value=lambda: random.choice([0,1]),
)
PaydayLoan = gr.Dropdown(
label="Payday Loan (Don't Have: 0, Have: 1)",
choices=[0,1],
value=lambda: random.choice([0,1]),
)
with gr.Column():
label = gr.Label()
with gr.Row():
predict_btn = gr.Button(value="Predict")
predict_btn.click(
predict,
inputs=[
Annual_Income,
Monthly_Inhand_Salary,
Interest_Rate,
Num_of_Loan,
Delay_from_due_date,
Num_of_Delayed_Payment,
Credit_Mix,
Outstanding_Debt,
Credit_Utilization_Ratio,
Payment_of_Min_Amount,
Total_EMI_per_month,
Amount_invested_monthly,
Monthly_Balance,
Credit_History_Age_In_Years,
StudentLoan,
MortgageLoan,
PersonalLoan,
DebtConsolidationLoan,
Credit_BuilderLoan,
HomeEquityLoan,
NotSpecified,
AutoLoan,
PaydayLoan,
],
outputs=[label],
)
app.launch() |