File size: 2,530 Bytes
9abe193
 
 
 
bd6f231
9abe193
bd6f231
0b7c71e
7cd326f
9c43aaf
 
 
 
 
 
 
 
 
 
 
b711036
54b0001
b9cbd3a
54b0001
 
b711036
54b0001
 
 
9abe193
 
 
 
 
 
 
16ce300
9abe193
 
 
 
 
 
 
 
 
 
 
bd6f231
9abe193
 
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
import numpy as np
import pandas as pd 
import pickle
import gradio as gr
from catboost import CatBoostClassifier

clf = CatBoostClassifier()
clf.load_model("./loan_model.bin")
def predict(customerid: 0,
             gender: 'Female',
             married: 'No',
             dependents: 2,
             education: 'Graduate',
             self_employed: 'Yes',    
             applicantincome: 50083.0,
             coapplicantincome: 10.0,
             loanamount: 100.0,
             loan_amount_term: 24,
             credit_history: 0,
             property_area: 'Rural'):

    prediction_array = np.array([customerid, gender, married, dependents, education, self_employed, applicantincome, coapplicantincome, loanamount, loan_amount_term, credit_history, property_area])

    verdict = clf.predict(prediction_array)
    if verdict >= 0.5:
    
        print('Good Standing - Approved: "Applicant stand a higher chance paying back loan"')
    else:
        print('Bad Standing - Rejected: "Applicant stand a higher chance defaulting payment"')

with gr.Blocks() as demo:
    with gr.Row() as row1:
        customerid = gr.Slider(1,1000000000, label="ClientID", interactive = True)
        gender = gr.Dropdown(choices=[0,1], label="Gender")
        married = gr.Dropdown(choices=[0,1], label="Marital Status")
        dependents = gr.Dropdown(choices=[0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20], label="Dependants")
        education = gr.Dropdown(choices=["Graduate", "Not Graduate"], label="Education")
        self_employed = gr.Dropdown(choices=[0,1], label="Employment Status")
        applicantincome = gr.Slider(1,100000, label = "Applicant's Income", interactive = True)
        coapplicantincome = gr.Slider(1,100000, label = "CoApplicant's Income", interactive = True)
        loanamount = gr.Slider(1,100000, label = "Loan Amount", interactive = True)
        loan_amount_term = gr.Slider(1,480, label = "Loan Period", interactive = True)
        credit_history = gr.Dropdown(choices=[0,1], label="Credit history")
        property_area = gr.Dropdown(choices=["Rural", "Urban"], label="Property Area")

        submit = gr.Button(value = 'Predict')
        output = gr.Textbox(label = "Verdict:", interactive = False)
        
        submit.click(predict, input = [customerid, gender, married, dependents, education, self_employed, applicantincome, coapplicantincome, loanamount, loan_amount_term, credit_history, property_area], outputs = [output])

        demo.launch(share = False, debut = False)