Upload 5 files
Browse files- Approval_Credit_prediction_model.joblib +3 -0
- Credit_Card_Approval.py +57 -0
- Feature_scaler.joblib +3 -0
- encoder.joblib +3 -0
- requirements.txt +2 -0
Approval_Credit_prediction_model.joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:1bc39e76b66343512ee37728dc2d0f97ce3c0eccc15e9b7e815a5c163b0d37f6
|
3 |
+
size 61679353
|
Credit_Card_Approval.py
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from joblib import load
|
2 |
+
import numpy as np
|
3 |
+
import gradio as gr
|
4 |
+
|
5 |
+
# Load the model and transformers
|
6 |
+
encoder = load("encoder.joblib")
|
7 |
+
feature_scaler = load("Feature_scaler.joblib")
|
8 |
+
model = load("Approval_Credit_prediction_model.joblib")
|
9 |
+
|
10 |
+
|
11 |
+
def credit_classification(gender, car, properties, children, annual_income, education_level, marital_status, housing, age, work, mobile_phone, work_phone, phone, email, job, long_month, status):
|
12 |
+
gender = encoder['CODE_GENDER'].transform([gender])[0]
|
13 |
+
car = encoder["FLAG_OWN_CAR"].transform([car])[0]
|
14 |
+
properties = encoder['FLAG_OWN_REALTY'].transform([properties])[0]
|
15 |
+
children = encoder["CNT_CHILDREN"].transform([children])[0]
|
16 |
+
education_level = encoder["NAME_EDUCATION_TYPE"].transform([education_level])[0]
|
17 |
+
marital_status = encoder["NAME_FAMILY_STATUS"].transform([marital_status])[0]
|
18 |
+
housing = encoder["NAME_HOUSING_TYPE"].transform([housing])[0]
|
19 |
+
job = encoder["JOB"].transform([job])[0]
|
20 |
+
status = encoder["STATUS"].transform([status])[0]
|
21 |
+
feature = np.array([[gender, car, properties, children, annual_income, education_level, marital_status, housing, age, work, mobile_phone, work_phone, phone, email, job, long_month * -1, status]])
|
22 |
+
feature = feature_scaler.transform(feature)
|
23 |
+
predict = model.predict(feature)
|
24 |
+
predict = predict[0]
|
25 |
+
if predict == 0:
|
26 |
+
return gr.HTML(f"<div style='background-color:green; color:white; padding:10px; border-radius:5px;'>You are Not Risk, your credit card will get approval</div>")
|
27 |
+
else:
|
28 |
+
return gr.HTML(f"<div style='background-color:red; color:white; padding:10px; border-radius:5px;'>You are Risk, your credit card may be declined</div>")
|
29 |
+
|
30 |
+
# Define input components
|
31 |
+
inputs = [
|
32 |
+
gr.Dropdown(["F", "M"], label="Gender"),
|
33 |
+
gr.Dropdown(["N", "Y"], label="Do you have cars?"),
|
34 |
+
gr.Dropdown(["N", "Y"], label="Do you have property?"),
|
35 |
+
gr.Dropdown(['2+ children', 'No children', '1 children'], label="How many children do you have?"),
|
36 |
+
gr.Number(label="Annual Income($)"),
|
37 |
+
gr.Dropdown(['Secondary / secondary special', 'Higher education', 'Incomplete higher', 'Lower secondary', 'Academic degree'], label="Your last education"),
|
38 |
+
gr.Dropdown(['Married', 'Single / not married', 'Civil marriage', 'Separated', 'Widow'], label="Your marital status"),
|
39 |
+
gr.Dropdown(['With parents', 'House / apartment', 'Rented apartment', 'Municipal apartment', 'Co-op apartment', 'Office apartment'], label="Your housing type"),
|
40 |
+
gr.Number(label="Age"),
|
41 |
+
gr.Number(label="Years of work"),
|
42 |
+
gr.Dropdown([0, 1], label="Do you have mobile phone? (0 for 'no' 1 for 'yes')"),
|
43 |
+
gr.Dropdown([0, 1], label="Do you have work phone? (0 for 'no' 1 for 'yes')"),
|
44 |
+
gr.Dropdown([0, 1], label="Do you have phone? (0 for 'no' 1 for 'yes')"),
|
45 |
+
gr.Dropdown([0, 1], label="Do you have email? (0 for 'no' 1 for 'yes')"),
|
46 |
+
gr.Dropdown(['Managers', 'Private service staff', 'Laborers', 'Core staff', 'Drivers', 'High skill tech staff', 'Realty agents', 'Secretaries', 'Accountants', 'Sales staff', 'Medicine staff', 'Waiters/barmen staff', 'Low-skill Laborers', 'Cleaning staff', 'HR staff', 'Cooking staff', 'Security staff', 'IT staff'], label="Your job (if you can't find your job on the list, choose similar job)"),
|
47 |
+
gr.Number(label="How long you have been using credit card?"),
|
48 |
+
gr.Dropdown(['paid off that month', '1-29 days past due', 'No loan for the month', '60-89 days overdue', '30-59 days past due', 'Overdue or bad debts, write-offs for more than 150 days', '90-119 days overdue', '120-149 days overdue'], label="Punctuality of payment")
|
49 |
+
]
|
50 |
+
|
51 |
+
# Create Gradio interface
|
52 |
+
UI = gr.Interface(fn=credit_classification,
|
53 |
+
inputs=inputs,
|
54 |
+
outputs=gr.HTML(label="Approval Credit Card Status"),
|
55 |
+
title="Credit Card Approval Prediction")
|
56 |
+
|
57 |
+
UI.launch()
|
Feature_scaler.joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:4e236bc05d7c2551b351a50e968fd63d528eb84f8d5f7a53ae0a9430985c7ce5
|
3 |
+
size 1983
|
encoder.joblib
ADDED
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
1 |
+
version https://git-lfs.github.com/spec/v1
|
2 |
+
oid sha256:514bb28b5c2283899ea4cb1fe95af3aaf86bd027ce615d2c21fbee00af7960c5
|
3 |
+
size 3750
|
requirements.txt
ADDED
@@ -0,0 +1,2 @@
|
|
|
|
|
|
|
1 |
+
numpy==1.26.4
|
2 |
+
scikit-learn == 1.6.0
|