Testys commited on
Commit
72e3d0f
1 Parent(s): e56f83f

Upload 2 files

Browse files
Files changed (2) hide show
  1. lightgbm.pickle +3 -0
  2. main.py +79 -0
lightgbm.pickle ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:4b7d22e69f268fb748603b825ed4b52a82665babcf684254dc74ee646e9f58e0
3
+ size 407716
main.py ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # importing python modules.
2
+ import streamlit as st
3
+ import joblib
4
+ import numpy as np
5
+ import time
6
+
7
+ # loading pickle files gotten from model
8
+ lightgbm_pickle = open(r"./lightgbm.pickle", "rb")
9
+ lgbm_model = joblib.load(lightgbm_pickle)
10
+
11
+ # column name for each column in the diabetes dataset.
12
+ column_names = ['cholesterol', 'glucose', 'hdl_chol', 'chol_hdl_ratio', 'age',
13
+ 'gender', 'weight', 'height', 'bmi', 'systolic_bp', 'diastolic_bp', 'waist', 'hip',
14
+ 'waist_hip_ratio', 'diabetes']
15
+
16
+
17
+ # function to receive user information.
18
+ def inputs():
19
+ # creating form for data inputs.
20
+ with st.form(key="diabetes_data"):
21
+ name = st.text_input("Patient's Name: ")
22
+ gender_obj = st.selectbox(label="Patient's Gender: ", options=["Male", "Female"])
23
+ if gender_obj == "Male":
24
+ gender = 1
25
+ else:
26
+ gender = 0
27
+
28
+ age = st.slider(label="Patient's Age: ", min_value=0, max_value=100)
29
+ chol = st.slider(label="Patient's Cholesterol Level(mg/dL): ", min_value=40, max_value=400)
30
+ glucose = st.slider(label="Patient's Sugar Level(mg/dL): ", min_value=40, max_value=250)
31
+ height_cm = st.number_input(label="Patient's Height(cm): ")
32
+ height = height_cm * 0.393701
33
+ weight_kg = st.number_input("Patient's Weight in(kg): ")
34
+ weight = weight_kg * 2.205
35
+ hdl_chol = st.slider(label="Patient's HDL Cholesterol(mg/dL): ", min_value=0, max_value=100)
36
+ waist = st.number_input("Patient's Waist Size(inches): ", step=1)
37
+ hip = st.number_input("Patient's Hip Size(inches): ", step=1)
38
+ systolic_bp = st.number_input(label="Patient's Systolic Blood Pressure(mmHg): ", step=1)
39
+ diastolic_bp = st.number_input(label="Patient's Diastolic Blood Pressure(mmHg): ", step=1)
40
+ submit = st.form_submit_button("Submit Test")
41
+ if submit:
42
+ bmi = weight_kg / ((height_cm / 100)**2)
43
+ chol_hdl_ratio = chol / hdl_chol
44
+ waist_hip_ratio = waist / hip
45
+ patient_data = [chol, glucose, hdl_chol, chol_hdl_ratio, age, gender, weight, height, bmi,
46
+ systolic_bp, diastolic_bp, waist, hip, waist_hip_ratio]
47
+ else:
48
+ patient_data = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
49
+ return patient_data
50
+
51
+
52
+ # function to create a dataframe and carry out prediction.
53
+ def predict(var_name):
54
+ pred = [var_name]
55
+ np_pred = np.array(pred)
56
+ score = lgbm_model.predict(np_pred)
57
+ return score
58
+
59
+
60
+ # function to run streamlit app
61
+ def run():
62
+ st.title("Diabetes Test App")
63
+ st.write("Diabetes is known as a very deadly disease if not diagnosed early. To make it easier for health "
64
+ "practitioners to diagnose this disease early, previous data have been accumulated to predict an accurate "
65
+ "result for new patients. "
66
+ "The Doctor is to retrieve necessary information from the patients to carry out this test."
67
+ " A diabetic patient should be notified early and should commence treatment immediately.")
68
+ info = inputs()
69
+ dia_score = predict(info)
70
+ with st.spinner(text="Diagnosing....."):
71
+ time.sleep(5)
72
+ if dia_score == 0:
73
+ st.error("Positive. Diabetes Diagnosed.")
74
+ else:
75
+ st.success("Negative. Diabetes not diagnosed.")
76
+
77
+
78
+ if __name__ == "__main__":
79
+ run()