File size: 1,866 Bytes
b0de5a2
 
 
 
 
 
b95fc25
b0de5a2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 pickle
import streamlit as st


# loading the saved model
loaded_model = pickle.load(open('rf_class.sav', 'rb'))


# creating a function for Prediction
def diabetes_prediction(input_data):
    # changing the input_data to numpy array
    input_data_as_numpy_array = np.asarray(input_data)
    # reshape the array as we are predicting for one instance
    input_data_reshaped = input_data_as_numpy_array.reshape(1,-1)
    prediction = loaded_model.predict(input_data_reshaped)
    if prediction[0] == 0:
        return 'Bad'
    else:
        return 'Good'


def main():
    # giving a title
    st.title('Risk Credit Prediction Web App')
    st.title('Enter numeric data only!. Use examples.')

    # getting the input data from the user
    Age = st.text_input('Age (example >>>	19-75)')
    Sex = st.text_input('Sex (example >>> male=1 female=0)')
    Job = st.text_input('Job (example >>> 2, 1, 3, 0)')
    Housing = st.text_input('Housing (example >>> own=3, free=2, rent=1)')
    Saving_accounts = st.text_input('Saving accounts (example >>> moderate=1, little=0, quite rich=3, rich=2)')
    Checking_account = st.text_input('Checking account (example >>> little=1, moderate=2, rich=3)')
    Credit_amount = st.text_input('Credit amount (example >>> 100-20 000 (Deutsch Mark))')
    Duration = st.text_input('Duration (example >>> 4-60 (month))')
    Purpose = st.text_input('Purpose (example >>> radio/TV = 0, education = 1, furniture/equipment = 2, car = 3, business = 4,domestic_appliances = 5, repairs = 6, vacation/others = 7)')

    # code for Prediction
    risk = ''

    # creating a button for Prediction
    if st.button('Submit'):
        risk = diabetes_prediction([Age, Sex, Job, Housing, Saving_accounts, Checking_account, Credit_amount, Duration, Purpose])

    st.success(risk)


if __name__ == '__main__':
    main()