-
Notifications
You must be signed in to change notification settings - Fork 1
/
Diabetes_Prediction_Webapp.py
77 lines (42 loc) · 1.66 KB
/
Diabetes_Prediction_Webapp.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
73
74
75
76
77
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 24 19:22:51 2023
@author: sparsh
"""
import numpy as np
import pickle
import streamlit as st
loaded_model = pickle.load(open('trained_model.sav', 'rb'))
#creating a fuction
def diabetes_function(input_data):
#changing the input_data to numpy array
input_dat_as_numpy_array = np.asarray(input_data)
#reshape the data as we are prediciting for one instance
input_data_reshaped = input_dat_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('Diabetes Prediction Web App')
# Getting the input Data from the user
Pregnancies = st.text_input('Number of Pregnancies')
Glucose = st.text_input('Glucose Level')
BloodPressure = st.text_input('BloodPressure Level')
SkinThickness = st.text_input('SkinThickness Value')
Insulin = st.text_input('Insulin Level')
BMI = st.text_input('BMI Value')
DiabetesPedigreeFunction = st.text_input('Diabetes Pedigree Function Value')
Age = st.text_input('Age of the Person')
#code for prediction
diagnosis = ''
# Creating a button for prediction
if st.button('Diabetes Test Result'):
diagnosis = diabetes_function([Pregnancies, Glucose, BloodPressure, SkinThickness, Insulin, BMI, DiabetesPedigreeFunction, Age])
st.success(diagnosis)
if __name__ == '__main__':
main()