File size: 3,026 Bytes
1de592b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
6c8028f
 
1de592b
21dafb3
1de592b
 
 
 
21dafb3
1de592b
21dafb3
1de592b
 
 
 
 
 
 
 
21dafb3
1de592b
21dafb3
1de592b
 
21dafb3
1de592b
21dafb3
1de592b
 
 
21dafb3
1de592b
21dafb3
1de592b
 
21dafb3
1de592b
21dafb3
1de592b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
101
102
import streamlit as st
import numpy as np
import pickle
import streamlit.components.v1 as components
from sklearn.preprocessing import LabelEncoder
le = LabelEncoder()

# Load the pickled model
def load_model():
    return pickle.load(open('Credit_Card_Classification_LogisticRegression.pkl','rb'))

# Function for model prediction
def model_prediction(model, features):
    predicted = str(model.predict(features)[0])
    return predicted
    
def transform(text):
    text = le.fit_transform(text)
    return text[0]

def app_design():
    # Add input fields for High, Open, and Low values
    image = 'credit.png'
    st.image(image, use_column_width=True)
    
    st.subheader("Enter the following values:")

    Gender = st.selectbox("Gender",('Male','Female'))
    if Gender == 'Male':
            Gender = 1
    else:
            Gender = 0
    Age= st.number_input("Age")
    Debt= st.number_input("Debt")
    Married= st.selectbox("Married",('Yes','No'))
    if Married == 'Yes':
            Married = 1
    else:
            Married = 0
    BankCustomer= st.number_input("Bank Customer")
    Industry= st.text_input("Industry")
    Industry = transform([Industry])
    Ethnicity= st.text_input("Ethnicity")
    Ethnicity = transform([Ethnicity])
    YearsEmployed = st.number_input("Years Employed")
    PriorDefault= st.selectbox("Prior Default",('Yes','No'))
    if PriorDefault == 'Yes':
            PriorDefault = 1
    else:
            PriorDefault = 0
    Employed= st.selectbox("Employed",('Yes','No'))
    if Employed == 'Yes':
            Employed = 1
    else:
            Employed = 0
    CreditScore = st.number_input("Credit Score")
    DriversLicense= st.selectbox("Drivers License",('Yes','No'))
    if DriversLicense == 'Yes':
            DriversLicense = 1
    else:
            DriversLicense = 0
    Citizen= st.selectbox("Citizen",('ByBirth','ByOtherMeans'))
    if Citizen == 'ByBirth':
            Citizen = 1
    else:
            Citizen = 0
    ZipCode= st.number_input("ZipCode")
    Income= st.number_input("Income")
 
    # Create a feature list from the user inputs
    features = [[Gender, Age,Debt,Married,BankCustomer,Industry,Ethnicity,YearsEmployed,PriorDefault,Employed,CreditScore,DriversLicense,Citizen,ZipCode,Income]]
    
    # Load the model
    model = load_model()
    
    # Make a prediction when the user clicks the "Predict" button
    if st.button('Predict Status'):
        predicted_value = model_prediction(model, features)
        if(predicted_value==1):
            st.success(f"The credit card is approved") 

        else:
            st.success(f"The credit card is not approved") 
        



def main():

        # Set the app title and add your website name and logo
        st.set_page_config(
        page_title="Credit Card Classification Model",
        page_icon=":chart_with_upwards_trend:",
        )

        
        st.title("Welcome to our Credit Card Classification Model!")
        app_design()

    
if __name__ == '__main__':
        main()