-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
54 lines (36 loc) · 1.48 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
import numpy as np
from sklearn.model_selection import train_test_split
from sklearn import svm
from sklearn.metrics import accuracy_score
import pickle
import streamlit as st
loaded_model = pickle.load(open('trained_model.csv', 'rb'))
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():
st.title("Diabetics Prediction Web App")
#getting i/p data from user
Pregnancies = st.text_input('No.of Pregnancies')
Glucose = st.text_input('Glucose Level')
BloodPressure = st.text_input('Blood Pressure Level')
SkinThickness = st.text_input('Skin Thickness 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 Person')
# code for prediction
diagnosis = " "
if st.button('Diabetes Test Result'):
diagnosis = diabetes_prediction([Pregnancies, Glucose, BloodPressure, SkinThickness, Insulin, BMI, DiabetesPedigreeFunction, Age])
st.success(diagnosis)
if __name__ == '__main__':
main()