-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
72 lines (42 loc) · 1.83 KB
/
app.py
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
import numpy as np
import pickle
import streamlit as st
from sklearn.model_selection import train_test_split
# loading the saved model
# loading the saved model
with open(r"trained_model.sav", 'rb') as file:
loaded_model = pickle.load(file)
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)
print(prediction)
if (prediction[0] == 0):
return 'The person is not diabetic'
else:
return 'The person is diabetic'
def main():
# giving a title
st.title(':violet[Diabetes Prediction Web App]')
# getting the input data from the user
col1,col2=st.columns(2)
with col1:
Pregnancies = st.text_input(':blue[Number of Pregnancies]')
Glucose = st.text_input(':blue[Glucose Level]')
BloodPressure = st.text_input(':blue[Blood Pressure value]')
SkinThickness = st.text_input(':blue[Skin Thickness value]')
with col2:
Insulin = st.text_input(':blue[Insulin Level]')
BMI = st.text_input(':blue[BMI value]')
DiabetesPedigreeFunction = st.text_input(':blue[Diabetes Pedigree Function value]')
Age = st.text_input(':blue[Age of the Person]')
# code for Prediction
diagnosis = ''
# creating a button for Prediction
if st.button('Diabetes Test Result'):
diagnosis = diabetes_prediction([Pregnancies, Glucose, BloodPressure, SkinThickness, Insulin, BMI, DiabetesPedigreeFunction, Age])
st.success(diagnosis)
if __name__ == '__main__':
main()