unknown commited on
Commit
33dc257
1 Parent(s): d3f5ff6

Application Deploment

Browse files
Files changed (3) hide show
  1. .ipynb_checkpoints/app-checkpoint.py +147 -0
  2. app.py +147 -0
  3. xgb.pkl +3 -0
.ipynb_checkpoints/app-checkpoint.py ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import joblib
2
+
3
+ model = joblib.load("xgb.pkl")
4
+
5
+
6
+ def predict(*args):
7
+ input_data = []
8
+
9
+ for i in args:
10
+ input_data.append(float(i))
11
+
12
+ input_data = np.asarray(input_data)
13
+ # reshape the array as we are predicting for one instance
14
+ input_data_reshaped = input_data.reshape(1, -1)
15
+
16
+ prediction = model.predict(input_data_reshaped)
17
+
18
+ if prediction[0] == 0:
19
+ return "The Credit Score is Good"
20
+ elif prediction[0] == 1:
21
+ return "The Credit Score is Poor"
22
+ else:
23
+ return "The Credit Score is Standard"
24
+
25
+ with gr.Blocks() as app:
26
+ gr.Markdown(
27
+ """
28
+ **Credit Score Classification**"""
29
+ )
30
+ with gr.Row():
31
+ with gr.Column():
32
+ Annual_Income = gr.TextArea(label="Annual Income")
33
+ Monthly_Inhand_Salary = gr.TextArea(label="Monthly Inhand Salary")
34
+ Interest_Rate = gr.TextArea(label="Interest Rate")
35
+ Num_of_Loan = gr.Slider(
36
+ label="Number of Loans", minimum=1, maximum=10, step=1, randomize=True
37
+ )
38
+ Delay_from_due_date = gr.Slider(
39
+ label="Number of Delayed Days",
40
+ minimum=-100,
41
+ maximum=100,
42
+ step=1,
43
+ randomize=True,
44
+ )
45
+ Num_of_Delayed_Payment = gr.Slider(
46
+ label="Number of Delayed Payments",
47
+ minimum=1,
48
+ maximum=10,
49
+ step=1,
50
+ randomize=True,
51
+ )
52
+ Credit_Mix = gr.Dropdown(
53
+ label="Credit Mix (Bad: 0, Don't Have: 1, Good: 2, Standard: 3)",
54
+ choices=[0,1,2,3],
55
+ value=lambda: random.choice([0,1,2,3]),
56
+ )
57
+ Outstanding_Debt = gr.TextArea(label="Outstanding Debt")
58
+ Credit_Utilization_Ratio = gr.TextArea(label="Credit Utilization Ratio")
59
+ Payment_of_Min_Amount = gr.Dropdown(
60
+ label="Payment of Minimum Amount (NM: 0, No: 1, Yes: 2)",
61
+ choices=[0,1,2],
62
+ value=lambda: random.choice([0,1,2]),
63
+ )
64
+ Total_EMI_per_month = gr.TextArea(label="Total Equated Monthly Installment")
65
+ Amount_invested_monthly = gr.TextArea(label="Amount Invested Monthly")
66
+ Monthly_Balance = gr.TextArea(label="Monthly Balance")
67
+ Credit_History_Age_In_Years = gr.TextArea(label="Credit History in Years")
68
+ StudentLoan = gr.Dropdown(
69
+ label="Student Loan (Don't Have: 0, Have: 1)",
70
+ choices=[0,1],
71
+ value=lambda: random.choice([0,1]),
72
+ )
73
+ MortgageLoan= gr.Dropdown(
74
+ label="Mortage Loan (Don't Have: 0, Have: 1)",
75
+ choices=[0,1],
76
+ value=lambda: random.choice([0,1]),
77
+ )
78
+ PersonalLoan = gr.Dropdown(
79
+ label="Personal Loan (Don't Have: 0, Have: 1)",
80
+ choices=[0,1],
81
+ value=lambda: random.choice([0,1]),
82
+ )
83
+ DebtConsolidationLoan = gr.Dropdown(
84
+ label="Debt Consolidation Loan (Don't Have: 0, Have: 1)",
85
+ choices=[0,1],
86
+ value=lambda: random.choice([0,1]),
87
+ )
88
+ Credit_BuilderLoan = gr.Dropdown(
89
+ label="Credit Builder Loan (Don't Have: 0, Have: 1)",
90
+ choices=[0,1],
91
+ value=lambda: random.choice([0,1]),
92
+ )
93
+ HomeEquityLoan = gr.Dropdown(
94
+ label="Home Equity Loan (Don't Have: 0, Have: 1)",
95
+ choices=[0,1],
96
+ value=lambda: random.choice([0,1]),
97
+ )
98
+ NotSpecified = gr.Dropdown(
99
+ label="Unspecified Loan (Don't Have: 0, Have: 1)",
100
+ choices=[0,1],
101
+ value=lambda: random.choice([0,1]),
102
+ )
103
+ AutoLoan = gr.Dropdown(
104
+ label="Auto Loan (Don't Have: 0, Have: 1)",
105
+ choices=[0,1],
106
+ value=lambda: random.choice([0,1]),
107
+ )
108
+ PaydayLoan = gr.Dropdown(
109
+ label="Payday Loan (Don't Have: 0, Have: 1)",
110
+ choices=[0,1],
111
+ value=lambda: random.choice([0,1]),
112
+ )
113
+ with gr.Column():
114
+ label = gr.Label()
115
+ with gr.Row():
116
+ predict_btn = gr.Button(value="Predict")
117
+ predict_btn.click(
118
+ predict,
119
+ inputs=[
120
+ Annual_Income,
121
+ Monthly_Inhand_Salary,
122
+ Interest_Rate,
123
+ Num_of_Loan,
124
+ Delay_from_due_date,
125
+ Num_of_Delayed_Payment,
126
+ Credit_Mix,
127
+ Outstanding_Debt,
128
+ Credit_Utilization_Ratio,
129
+ Payment_of_Min_Amount,
130
+ Total_EMI_per_month,
131
+ Amount_invested_monthly,
132
+ Monthly_Balance,
133
+ Credit_History_Age_In_Years,
134
+ StudentLoan,
135
+ MortgageLoan,
136
+ PersonalLoan,
137
+ DebtConsolidationLoan,
138
+ Credit_BuilderLoan,
139
+ HomeEquityLoan,
140
+ NotSpecified,
141
+ AutoLoan,
142
+ PaydayLoan,
143
+ ],
144
+ outputs=[label],
145
+ )
146
+
147
+ app.launch()
app.py ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import joblib
2
+
3
+ model = joblib.load("xgb.pkl")
4
+
5
+
6
+ def predict(*args):
7
+ input_data = []
8
+
9
+ for i in args:
10
+ input_data.append(float(i))
11
+
12
+ input_data = np.asarray(input_data)
13
+ # reshape the array as we are predicting for one instance
14
+ input_data_reshaped = input_data.reshape(1, -1)
15
+
16
+ prediction = model.predict(input_data_reshaped)
17
+
18
+ if prediction[0] == 0:
19
+ return "The Credit Score is Good"
20
+ elif prediction[0] == 1:
21
+ return "The Credit Score is Poor"
22
+ else:
23
+ return "The Credit Score is Standard"
24
+
25
+ with gr.Blocks() as app:
26
+ gr.Markdown(
27
+ """
28
+ **Credit Score Classification**"""
29
+ )
30
+ with gr.Row():
31
+ with gr.Column():
32
+ Annual_Income = gr.TextArea(label="Annual Income")
33
+ Monthly_Inhand_Salary = gr.TextArea(label="Monthly Inhand Salary")
34
+ Interest_Rate = gr.TextArea(label="Interest Rate")
35
+ Num_of_Loan = gr.Slider(
36
+ label="Number of Loans", minimum=1, maximum=10, step=1, randomize=True
37
+ )
38
+ Delay_from_due_date = gr.Slider(
39
+ label="Number of Delayed Days",
40
+ minimum=-100,
41
+ maximum=100,
42
+ step=1,
43
+ randomize=True,
44
+ )
45
+ Num_of_Delayed_Payment = gr.Slider(
46
+ label="Number of Delayed Payments",
47
+ minimum=1,
48
+ maximum=10,
49
+ step=1,
50
+ randomize=True,
51
+ )
52
+ Credit_Mix = gr.Dropdown(
53
+ label="Credit Mix (Bad: 0, Don't Have: 1, Good: 2, Standard: 3)",
54
+ choices=[0,1,2,3],
55
+ value=lambda: random.choice([0,1,2,3]),
56
+ )
57
+ Outstanding_Debt = gr.TextArea(label="Outstanding Debt")
58
+ Credit_Utilization_Ratio = gr.TextArea(label="Credit Utilization Ratio")
59
+ Payment_of_Min_Amount = gr.Dropdown(
60
+ label="Payment of Minimum Amount (NM: 0, No: 1, Yes: 2)",
61
+ choices=[0,1,2],
62
+ value=lambda: random.choice([0,1,2]),
63
+ )
64
+ Total_EMI_per_month = gr.TextArea(label="Total Equated Monthly Installment")
65
+ Amount_invested_monthly = gr.TextArea(label="Amount Invested Monthly")
66
+ Monthly_Balance = gr.TextArea(label="Monthly Balance")
67
+ Credit_History_Age_In_Years = gr.TextArea(label="Credit History in Years")
68
+ StudentLoan = gr.Dropdown(
69
+ label="Student Loan (Don't Have: 0, Have: 1)",
70
+ choices=[0,1],
71
+ value=lambda: random.choice([0,1]),
72
+ )
73
+ MortgageLoan= gr.Dropdown(
74
+ label="Mortage Loan (Don't Have: 0, Have: 1)",
75
+ choices=[0,1],
76
+ value=lambda: random.choice([0,1]),
77
+ )
78
+ PersonalLoan = gr.Dropdown(
79
+ label="Personal Loan (Don't Have: 0, Have: 1)",
80
+ choices=[0,1],
81
+ value=lambda: random.choice([0,1]),
82
+ )
83
+ DebtConsolidationLoan = gr.Dropdown(
84
+ label="Debt Consolidation Loan (Don't Have: 0, Have: 1)",
85
+ choices=[0,1],
86
+ value=lambda: random.choice([0,1]),
87
+ )
88
+ Credit_BuilderLoan = gr.Dropdown(
89
+ label="Credit Builder Loan (Don't Have: 0, Have: 1)",
90
+ choices=[0,1],
91
+ value=lambda: random.choice([0,1]),
92
+ )
93
+ HomeEquityLoan = gr.Dropdown(
94
+ label="Home Equity Loan (Don't Have: 0, Have: 1)",
95
+ choices=[0,1],
96
+ value=lambda: random.choice([0,1]),
97
+ )
98
+ NotSpecified = gr.Dropdown(
99
+ label="Unspecified Loan (Don't Have: 0, Have: 1)",
100
+ choices=[0,1],
101
+ value=lambda: random.choice([0,1]),
102
+ )
103
+ AutoLoan = gr.Dropdown(
104
+ label="Auto Loan (Don't Have: 0, Have: 1)",
105
+ choices=[0,1],
106
+ value=lambda: random.choice([0,1]),
107
+ )
108
+ PaydayLoan = gr.Dropdown(
109
+ label="Payday Loan (Don't Have: 0, Have: 1)",
110
+ choices=[0,1],
111
+ value=lambda: random.choice([0,1]),
112
+ )
113
+ with gr.Column():
114
+ label = gr.Label()
115
+ with gr.Row():
116
+ predict_btn = gr.Button(value="Predict")
117
+ predict_btn.click(
118
+ predict,
119
+ inputs=[
120
+ Annual_Income,
121
+ Monthly_Inhand_Salary,
122
+ Interest_Rate,
123
+ Num_of_Loan,
124
+ Delay_from_due_date,
125
+ Num_of_Delayed_Payment,
126
+ Credit_Mix,
127
+ Outstanding_Debt,
128
+ Credit_Utilization_Ratio,
129
+ Payment_of_Min_Amount,
130
+ Total_EMI_per_month,
131
+ Amount_invested_monthly,
132
+ Monthly_Balance,
133
+ Credit_History_Age_In_Years,
134
+ StudentLoan,
135
+ MortgageLoan,
136
+ PersonalLoan,
137
+ DebtConsolidationLoan,
138
+ Credit_BuilderLoan,
139
+ HomeEquityLoan,
140
+ NotSpecified,
141
+ AutoLoan,
142
+ PaydayLoan,
143
+ ],
144
+ outputs=[label],
145
+ )
146
+
147
+ app.launch()
xgb.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:c9513f93dbdeda53310324f391d0186442155192b6c5128505dfdfb3fcaf7cbe
3
+ size 28917068