sakthi07 commited on
Commit
4549784
·
1 Parent(s): 7caa41a

Added app.py HbA1cData, requirements.txt

Browse files
Hba1cData/dim_patients_final_rev01.csv ADDED
The diff for this file is too large to render. See raw diff
 
Hba1cData/fact_visits_final_rev01.csv ADDED
The diff for this file is too large to render. See raw diff
 
app.py ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import warnings
2
+ warnings.filterwarnings("ignore")
3
+
4
+ import streamlit as st
5
+ import numpy as np
6
+ import pandas as pd
7
+ import mlflow
8
+ import mlflow.sklearn
9
+ import os
10
+ from datetime import datetime
11
+
12
+ st.set_page_config(page_title="HBA1C Prediction", layout="centered")
13
+
14
+ df_patients = pd.read_csv("Hba1cData/dim_patients_final_rev01.csv")
15
+ patient_ids = df_patients['patient_id'].tolist()
16
+
17
+ # Set the MLflow tracking URI to DagsHub
18
+ mlflow.set_tracking_uri("https://dagshub.com/sakthi-t/healthcaremlflow.mlflow")
19
+
20
+ # Load the model from MLflow model registry
21
+ model_name = "ElasticnetHealthcareModel"
22
+ model_version = 3
23
+ model_uri = f"models:/{model_name}/{model_version}"
24
+ loaded_model = mlflow.sklearn.load_model(model_uri)
25
+
26
+ def predict_hba1c(patient_id, visited_date, sugar):
27
+ # Prepare input data
28
+ visited_date = pd.to_datetime(visited_date)
29
+ data = {
30
+ 'patient_id': [patient_id],
31
+ 'sugar': [sugar],
32
+ 'year': [visited_date.year],
33
+ 'month': [visited_date.month],
34
+ 'day': [visited_date.day]
35
+ }
36
+ input_df = pd.DataFrame(data)
37
+
38
+ # Make prediction
39
+ prediction = loaded_model.predict(input_df)
40
+ return prediction[0]
41
+
42
+ # Streamlit interface
43
+ st.title("HBA1C Prediction")
44
+ st.write("Select Patient ID, Visited Date, and Sugar value to predict HBA1C.")
45
+
46
+ st.markdown(
47
+ """
48
+ <div style="background-color: #FF9798; color: white; padding: 10px; border-radius: 5px;">
49
+ Choose sugar levels between 50 and 600. HBA1C levels are influenced by sugar values: higher sugar typically results in higher HBA1C.
50
+ This machine learning project uses synthetic data and is not a definitive method to determine HBA1C levels. For accurate results,
51
+ please select a date within 2024. The dataset contains dates from 2023 to April 2024. Patient names are fictional. Users can only select
52
+ from existing patient IDs, and there is no correlation between User ID and sugar levels.
53
+ </div>
54
+ """, unsafe_allow_html=True
55
+ )
56
+
57
+ patient_id = st.selectbox("Patient ID", patient_ids)
58
+ visited_date = st.date_input("Visited Date", min_value=datetime(2023, 1, 1), max_value=datetime(2024, 4, 30))
59
+ sugar = st.number_input("Sugar", min_value=50.0, max_value=600.0, value=100.0)
60
+
61
+ if st.button("Predict HBA1C"):
62
+ prediction = predict_hba1c(patient_id, visited_date, sugar)
63
+ st.write(f"Predicted HBA1C: {prediction}")
requirements.txt ADDED
@@ -0,0 +1,107 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ alembic==1.13.1
2
+ altair==5.3.0
3
+ aniso8601==9.0.1
4
+ anyio==4.4.0
5
+ appdirs==1.4.4
6
+ attrs==23.2.0
7
+ backoff==2.2.1
8
+ blinker==1.8.2
9
+ boto3==1.34.115
10
+ botocore==1.34.115
11
+ cachetools==5.3.3
12
+ certifi==2024.2.2
13
+ charset-normalizer==3.3.2
14
+ click==8.1.7
15
+ cloudpickle==3.0.0
16
+ colorama==0.4.6
17
+ commonmark==0.9.1
18
+ contourpy==1.2.1
19
+ cycler==0.12.1
20
+ dacite==1.6.0
21
+ dagshub==0.3.27
22
+ dataclasses-json==0.6.6
23
+ Deprecated==1.2.14
24
+ docker==7.1.0
25
+ entrypoints==0.4
26
+ Flask==3.0.3
27
+ fonttools==4.52.4
28
+ fusepy==3.0.1
29
+ gitdb==4.0.11
30
+ GitPython==3.1.43
31
+ gql==3.5.0
32
+ graphene==3.3
33
+ graphql-core==3.2.3
34
+ graphql-relay==3.2.0
35
+ greenlet==3.0.3
36
+ h11==0.14.0
37
+ httpcore==0.16.3
38
+ httpx==0.23.3
39
+ idna==3.7
40
+ importlib-metadata==7.0.0
41
+ itsdangerous==2.2.0
42
+ Jinja2==3.1.4
43
+ jmespath==1.0.1
44
+ joblib==1.4.2
45
+ jsonschema==4.22.0
46
+ jsonschema-specifications==2023.12.1
47
+ kiwisolver==1.4.5
48
+ Mako==1.3.5
49
+ Markdown==3.6
50
+ markdown-it-py==3.0.0
51
+ MarkupSafe==2.1.5
52
+ marshmallow==3.21.2
53
+ matplotlib==3.9.0
54
+ mdurl==0.1.2
55
+ mlflow==2.13.0
56
+ multidict==6.0.5
57
+ mypy-extensions==1.0.0
58
+ numpy==1.26.4
59
+ opentelemetry-api==1.24.0
60
+ opentelemetry-sdk==1.24.0
61
+ opentelemetry-semantic-conventions==0.45b0
62
+ packaging==24.0
63
+ pandas==2.2.2
64
+ pathvalidate==3.0.0
65
+ pillow==10.3.0
66
+ protobuf==4.25.3
67
+ pyarrow==15.0.2
68
+ pydeck==0.9.1
69
+ Pygments==2.18.0
70
+ pyparsing==3.1.2
71
+ python-dateutil==2.9.0.post0
72
+ pytz==2024.1
73
+ pywin32==306
74
+ PyYAML==6.0.1
75
+ querystring-parser==1.2.4
76
+ referencing==0.35.1
77
+ requests==2.32.3
78
+ requests-toolbelt==1.0.0
79
+ rfc3986==1.5.0
80
+ rich==13.1.0
81
+ rpds-py==0.18.1
82
+ s3transfer==0.10.1
83
+ scikit-learn==1.5.0
84
+ scipy==1.13.1
85
+ setuptools==70.0.0
86
+ six==1.16.0
87
+ smmap==5.0.1
88
+ sniffio==1.3.1
89
+ SQLAlchemy==2.0.30
90
+ sqlparse==0.5.0
91
+ streamlit==1.35.0
92
+ tenacity==8.2.3
93
+ threadpoolctl==3.5.0
94
+ toml==0.10.2
95
+ toolz==0.12.1
96
+ tornado==6.4
97
+ treelib==1.6.4
98
+ typing-inspect==0.9.0
99
+ typing_extensions==4.12.0
100
+ tzdata==2024.1
101
+ urllib3==2.2.1
102
+ waitress==3.0.0
103
+ watchdog==4.0.1
104
+ Werkzeug==3.0.3
105
+ wrapt==1.16.0
106
+ yarl==1.9.4
107
+ zipp==3.19.0