Spaces:
Sleeping
Sleeping
Commit
•
b0de5a2
1
Parent(s):
7fdcf11
app.py
Browse files
app.py
ADDED
@@ -0,0 +1,50 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import numpy as np
|
2 |
+
import pickle
|
3 |
+
import streamlit as st
|
4 |
+
|
5 |
+
|
6 |
+
# loading the saved model
|
7 |
+
loaded_model = pickle.load(open('C:/Users/dizda/risk/deploy/rf_class.sav', 'rb'))
|
8 |
+
|
9 |
+
|
10 |
+
# creating a function for Prediction
|
11 |
+
def diabetes_prediction(input_data):
|
12 |
+
# changing the input_data to numpy array
|
13 |
+
input_data_as_numpy_array = np.asarray(input_data)
|
14 |
+
# reshape the array as we are predicting for one instance
|
15 |
+
input_data_reshaped = input_data_as_numpy_array.reshape(1,-1)
|
16 |
+
prediction = loaded_model.predict(input_data_reshaped)
|
17 |
+
if prediction[0] == 0:
|
18 |
+
return 'Bad'
|
19 |
+
else:
|
20 |
+
return 'Good'
|
21 |
+
|
22 |
+
|
23 |
+
def main():
|
24 |
+
# giving a title
|
25 |
+
st.title('Risk Credit Prediction Web App')
|
26 |
+
st.title('Enter numeric data only!. Use examples.')
|
27 |
+
|
28 |
+
# getting the input data from the user
|
29 |
+
Age = st.text_input('Age (example >>> 19-75)')
|
30 |
+
Sex = st.text_input('Sex (example >>> male=1 female=0)')
|
31 |
+
Job = st.text_input('Job (example >>> 2, 1, 3, 0)')
|
32 |
+
Housing = st.text_input('Housing (example >>> own=3, free=2, rent=1)')
|
33 |
+
Saving_accounts = st.text_input('Saving accounts (example >>> moderate=1, little=0, quite rich=3, rich=2)')
|
34 |
+
Checking_account = st.text_input('Checking account (example >>> little=1, moderate=2, rich=3)')
|
35 |
+
Credit_amount = st.text_input('Credit amount (example >>> 100-20 000 (Deutsch Mark))')
|
36 |
+
Duration = st.text_input('Duration (example >>> 4-60 (month))')
|
37 |
+
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)')
|
38 |
+
|
39 |
+
# code for Prediction
|
40 |
+
risk = ''
|
41 |
+
|
42 |
+
# creating a button for Prediction
|
43 |
+
if st.button('Submit'):
|
44 |
+
risk = diabetes_prediction([Age, Sex, Job, Housing, Saving_accounts, Checking_account, Credit_amount, Duration, Purpose])
|
45 |
+
|
46 |
+
st.success(risk)
|
47 |
+
|
48 |
+
|
49 |
+
if __name__ == '__main__':
|
50 |
+
main()
|