-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
49 lines (37 loc) · 1.6 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
import numpy as np
import pickle
import streamlit
# loaded the saved model
loaded_model = pickle.load(open('trained_model.sav','rb'))
# creating a functoin for prediction
def diabates_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 preson is diabetic'
def main():
# giving a title
streamlit.title('Diabates Prediction Web App')
# getting the input data from the user
Pregnancies = streamlit.text_input('Numer of Pregnencies: ')
Glucose = streamlit.text_input('Glucose lavel: ')
BloodPressure = streamlit.text_input('Blood Pressure value: ')
SkinThickness = streamlit.text_input('Skin Thickness value: ')
Insulin = streamlit.text_input('Insulin lavel: ')
BMI = streamlit.text_input('BMI value: ')
DiabetesPedigreeFunction = streamlit.text_input('Diabetes Pedigree Function value: ')
Age = streamlit.text_input('Age of the person: ')
# code for prediction
diagnosis = ''
# create a button for prediction
if streamlit.button('Diabetes Test Result'):
diagnosis = diabates_prediction([Pregnancies,Glucose,BloodPressure,SkinThickness,Insulin,BMI,DiabetesPedigreeFunction,Age])
streamlit.success(diagnosis)
if __name__ == '__main__':
main()