Spaces:
Running
Running
Commit
·
62a74f7
1
Parent(s):
aa1126a
Update app.py
Browse files
app.py
CHANGED
@@ -1,38 +1,37 @@
|
|
1 |
import gradio as gr
|
2 |
-
import numpy as np
|
3 |
import joblib
|
4 |
|
5 |
# Load the trained model
|
6 |
-
model = joblib.load(
|
7 |
|
8 |
|
9 |
-
|
10 |
-
|
11 |
-
|
12 |
-
|
13 |
-
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
input_dict = {
|
24 |
-
|
25 |
-
|
26 |
-
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
}
|
37 |
# Convert the dictionary to a 2D array
|
38 |
input_array = [list(input_dict.values())]
|
@@ -43,22 +42,31 @@ def predict_loan_status(int_rate,
|
|
43 |
else:
|
44 |
return "Loan not fully paid"
|
45 |
|
|
|
46 |
inputs = [
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
outputs = [gr.Label(num_top_classes=2)]
|
61 |
|
62 |
title = "Loan Approval Classifier"
|
63 |
-
description =
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
|
|
2 |
import joblib
|
3 |
|
4 |
# Load the trained model
|
5 |
+
model = joblib.load("loan_classifier.joblib")
|
6 |
|
7 |
|
8 |
+
def predict_loan_status(
|
9 |
+
int_rate,
|
10 |
+
installment,
|
11 |
+
log_annual_inc,
|
12 |
+
dti,
|
13 |
+
fico,
|
14 |
+
revol_bal,
|
15 |
+
revol_util,
|
16 |
+
inq_last_6mths,
|
17 |
+
delinq_2yrs,
|
18 |
+
pub_rec,
|
19 |
+
installment_to_income_ratio,
|
20 |
+
credit_history,
|
21 |
+
):
|
22 |
input_dict = {
|
23 |
+
"int.rate": int_rate,
|
24 |
+
"installment": installment,
|
25 |
+
"log.annual.inc": log_annual_inc,
|
26 |
+
"dti": dti,
|
27 |
+
"fico": fico,
|
28 |
+
"revol.bal": revol_bal,
|
29 |
+
"revol.util": revol_util,
|
30 |
+
"inq.last.6mths": inq_last_6mths,
|
31 |
+
"delinq.2yrs": delinq_2yrs,
|
32 |
+
"pub.rec": pub_rec,
|
33 |
+
"installment_to_income_ratio": installment_to_income_ratio,
|
34 |
+
"credit_history": credit_history,
|
35 |
}
|
36 |
# Convert the dictionary to a 2D array
|
37 |
input_array = [list(input_dict.values())]
|
|
|
42 |
else:
|
43 |
return "Loan not fully paid"
|
44 |
|
45 |
+
|
46 |
inputs = [
|
47 |
+
gr.Slider(0.06, 0.23, step=0.01, label="Interest Rate"),
|
48 |
+
gr.Slider(100, 950, step=10, label="Installment"),
|
49 |
+
gr.Slider(7, 15, step=0.1, label="Log Annual Income"),
|
50 |
+
gr.Slider(0, 40, step=1, label="DTI Ratio"),
|
51 |
+
gr.Slider(600, 850, step=1, label="FICO Score"),
|
52 |
+
gr.Slider(0, 120000, step=1000, label="Revolving Balance"),
|
53 |
+
gr.Slider(0, 120, step=1, label="Revolving Utilization"),
|
54 |
+
gr.Slider(0, 10, step=1, label="Inquiries in Last 6 Months"),
|
55 |
+
gr.Slider(0, 20, step=1, label="Delinquencies in Last 2 Years"),
|
56 |
+
gr.Slider(0, 10, step=1, label="Public Records"),
|
57 |
+
gr.Slider(0, 5, step=0.1, label="Installment to Income Ratio"),
|
58 |
+
gr.Slider(0, 1, step=0.01, label="Credit History"),
|
59 |
+
]
|
60 |
outputs = [gr.Label(num_top_classes=2)]
|
61 |
|
62 |
title = "Loan Approval Classifier"
|
63 |
+
description = (
|
64 |
+
"Enter the details of the loan applicant to check if the loan is approved or not."
|
65 |
+
)
|
66 |
+
gr.Interface(
|
67 |
+
fn=predict_loan_status,
|
68 |
+
inputs=inputs,
|
69 |
+
outputs=outputs,
|
70 |
+
title=title,
|
71 |
+
description=description,
|
72 |
+
).launch()
|