-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpredict.py
More file actions
100 lines (95 loc) · 2.69 KB
/
predict.py
File metadata and controls
100 lines (95 loc) · 2.69 KB
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
import gradio as gr
import numpy as np
import pandas as pd
import joblib
model = joblib.load('models/model.pkl')
columns = [ "Gender",
"Age",
"Debt",
"Married",
"BankCustomer",
"Industry",
"Ethnicity",
"YearsEmployed",
"PriorDefault",
"Employed",
"CreditScore",
"DriversLicense",
"Citizen",
"ZipCode",
"Income"]
# Placeholder function for prediction (replace with your trained model)
def predict_approval(
Gender,
Age,
Debt,
Married,
BankCustomer,
Industry,
Ethnicity,
YearsEmployed,
PriorDefault,
Employed,
CreditScore,
DriversLicense,
Citizen,
ZipCode,
Income
):
x = [ Gender,
Age,
Debt,
Married,
BankCustomer,
Industry,
Ethnicity,
YearsEmployed,
PriorDefault,
Employed,
CreditScore,
DriversLicense,
Citizen,
ZipCode,
Income]
for i in range(len(x)):
c = x[i]
if c =="Yes" or c== "Male":
x[i] = 1
elif c == "No" or c == "Female":
x[i] = 0
x = pd.DataFrame([x], columns=columns)
y = model.predict(x)
# Simple approval based on employment status (mock)
if y[0]:
return "Congratulation your card is Approved"
else:
return "Sorry We can not provide at this time but we will take you into account for next opportunities"
# Gradio interface definition
interface = gr.Interface(
fn=predict_approval,
inputs=[
gr.Radio(["Male", "Female"], label="Gender"),
gr.Slider(minimum=12, maximum=100, label="Age"),
gr.Number(label="Debt"),
gr.Radio(["Yes", "No"], label="Married"),
gr.Radio(["Yes", "No"], label="Bank Customer"),
gr.Radio(['CommunicationServices', 'ConsumerDiscretionary', 'ConsumerStaples',
'Education', 'Energy', 'Financials', 'Healthcare', 'Industrials',
'InformationTechnology', 'Materials', 'Real Estate', 'Research', 'Transport'
'Utilities'],label="Industry"),
gr.Radio(['Asian', 'Black', 'Latino', 'Other', 'White'], label="Ethnicity"),
gr.Slider(minimum=0, maximum=30, label="Years Employed"),
gr.Radio(["Yes", "No"], label="Prior Default"),
gr.Radio(["Yes", "No"], label="Employed"),
gr.Slider(minimum=0, maximum=100, label="Credit Score"),
gr.Radio(["Yes", "No"], label="Driver's License"),
gr.Radio(['ByBirth', 'ByOtherMeans', 'Temporary'], label="Citizen"),
gr.Number(label="Zip Code"),
gr.Number(label="Income"),
],
outputs="text",
title="Credit Card Approval Prediction",
description="Enter applicant information to predict credit card approval (placeholder results).",
)
# Launch the Gradio interface
interface.launch()