vafaei_ar commited on
Commit
2d1beae
·
1 Parent(s): 1d7af47

Initial Space with model + Gradio app

Browse files
Files changed (4) hide show
  1. .gitignore +174 -0
  2. app.py +207 -0
  3. models/README.md +8 -0
  4. requirements.txt +5 -0
.gitignore ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Byte-compiled / optimized / DLL files
2
+ __pycache__/
3
+ *.py[cod]
4
+ *$py.class
5
+
6
+ # C extensions
7
+ *.so
8
+
9
+ # Distribution / packaging
10
+ .Python
11
+ build/
12
+ develop-eggs/
13
+ dist/
14
+ downloads/
15
+ eggs/
16
+ .eggs/
17
+ lib/
18
+ lib64/
19
+ parts/
20
+ sdist/
21
+ var/
22
+ wheels/
23
+ share/python-wheels/
24
+ *.egg-info/
25
+ .installed.cfg
26
+ *.egg
27
+ MANIFEST
28
+
29
+ # PyInstaller
30
+ # Usually these files are written by a python script from a template
31
+ # before PyInstaller builds the exe, so as to inject date/other infos into it.
32
+ *.manifest
33
+ *.spec
34
+
35
+ # Installer logs
36
+ pip-log.txt
37
+ pip-delete-this-directory.txt
38
+
39
+ # Unit test / coverage reports
40
+ htmlcov/
41
+ .tox/
42
+ .nox/
43
+ .coverage
44
+ .coverage.*
45
+ .cache
46
+ nosetests.xml
47
+ coverage.xml
48
+ *.cover
49
+ *.py,cover
50
+ .hypothesis/
51
+ .pytest_cache/
52
+ cover/
53
+
54
+ # Translations
55
+ *.mo
56
+ *.pot
57
+
58
+ # Django stuff:
59
+ *.log
60
+ local_settings.py
61
+ db.sqlite3
62
+ db.sqlite3-journal
63
+
64
+ # Flask stuff:
65
+ instance/
66
+ .webassets-cache
67
+
68
+ # Scrapy stuff:
69
+ .scrapy
70
+
71
+ # Sphinx documentation
72
+ docs/_build/
73
+
74
+ # PyBuilder
75
+ .pybuilder/
76
+ target/
77
+
78
+ # Jupyter Notebook
79
+ .ipynb_checkpoints
80
+
81
+ # IPython
82
+ profile_default/
83
+ ipython_config.py
84
+
85
+ # pyenv
86
+ # For a library or package, you might want to ignore these files since the code is
87
+ # intended to run in multiple environments; otherwise, check them in:
88
+ # .python-version
89
+
90
+ # pipenv
91
+ # According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
92
+ # However, in case of collaboration, if having platform-specific dependencies or dependencies
93
+ # having no cross-platform support, pipenv may install dependencies that don't work, or not
94
+ # install all needed dependencies.
95
+ #Pipfile.lock
96
+
97
+ # UV
98
+ # Similar to Pipfile.lock, it is generally recommended to include uv.lock in version control.
99
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
100
+ # commonly ignored for libraries.
101
+ #uv.lock
102
+
103
+ # poetry
104
+ # Similar to Pipfile.lock, it is generally recommended to include poetry.lock in version control.
105
+ # This is especially recommended for binary packages to ensure reproducibility, and is more
106
+ # commonly ignored for libraries.
107
+ # https://python-poetry.org/docs/basic-usage/#commit-your-poetrylock-file-to-version-control
108
+ #poetry.lock
109
+
110
+ # pdm
111
+ # Similar to Pipfile.lock, it is generally recommended to include pdm.lock in version control.
112
+ #pdm.lock
113
+ # pdm stores project-wide configurations in .pdm.toml, but it is recommended to not include it
114
+ # in version control.
115
+ # https://pdm.fming.dev/latest/usage/project/#working-with-version-control
116
+ .pdm.toml
117
+ .pdm-python
118
+ .pdm-build/
119
+
120
+ # PEP 582; used by e.g. github.com/David-OConnor/pyflow and github.com/pdm-project/pdm
121
+ __pypackages__/
122
+
123
+ # Celery stuff
124
+ celerybeat-schedule
125
+ celerybeat.pid
126
+
127
+ # SageMath parsed files
128
+ *.sage.py
129
+
130
+ # Environments
131
+ .env
132
+ .venv
133
+ env/
134
+ venv/
135
+ ENV/
136
+ env.bak/
137
+ venv.bak/
138
+
139
+ # Spyder project settings
140
+ .spyderproject
141
+ .spyproject
142
+
143
+ # Rope project settings
144
+ .ropeproject
145
+
146
+ # mkdocs documentation
147
+ /site
148
+
149
+ # mypy
150
+ .mypy_cache/
151
+ .dmypy.json
152
+ dmypy.json
153
+
154
+ # Pyre type checker
155
+ .pyre/
156
+
157
+ # pytype static type analyzer
158
+ .pytype/
159
+
160
+ # Cython debug symbols
161
+ cython_debug/
162
+
163
+ # PyCharm
164
+ # JetBrains specific template is maintained in a separate JetBrains.gitignore that can
165
+ # be found at https://github.com/github/gitignore/blob/main/Global/JetBrains.gitignore
166
+ # and can be added to the global gitignore or merged into this file. For a more nuclear
167
+ # option (not recommended) you can uncomment the following to ignore the entire idea folder.
168
+ #.idea/
169
+
170
+ # Ruff stuff:
171
+ .ruff_cache/
172
+
173
+ # PyPI configuration file
174
+ .pypirc
app.py ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import joblib
4
+ import os
5
+ from sklearn.ensemble import RandomForestClassifier # Assuming RF, add others if needed
6
+
7
+ # Define categorical mappings
8
+ SEX_MAP = {'Female': 0, 'Male': 1}
9
+ ETHNICITY_MAP = {'Not Hispanic or Latino': 0, 'Hispanic or Latino': 1}
10
+ MARITAL_STATUS_MAP = {'Single': 0, 'Married': 1}
11
+ RACE_MAP = {
12
+ 'White': 0,
13
+ 'Asian': 1,
14
+ 'American Indian or Alaska Native': 2,
15
+ 'Native Hawaiian or Other Pacific Islander': 3,
16
+ 'Black or African American': 4,
17
+ 'Other Race': 5,
18
+ 'Unknown': 6
19
+ }
20
+
21
+ # Invert maps for display in dropdowns if necessary (or use keys directly)
22
+ RACE_CHOICES = list(RACE_MAP.keys())
23
+ SEX_CHOICES = list(SEX_MAP.keys())
24
+ ETHNICITY_CHOICES = list(ETHNICITY_MAP.keys())
25
+ MARITAL_STATUS_CHOICES = list(MARITAL_STATUS_MAP.keys())
26
+
27
+ MODEL_DIR = "./models"
28
+
29
+ def get_available_models():
30
+ if not os.path.exists(MODEL_DIR):
31
+ os.makedirs(MODEL_DIR) # Create models directory if it doesn't exist
32
+ return ["No models found. Please add .joblib models to the 'models' directory."]
33
+ models = [f for f in os.listdir(MODEL_DIR) if f.endswith(".joblib")]
34
+ if not models:
35
+ return ["No models found. Please add .joblib models to the 'models' directory."]
36
+ return models
37
+
38
+ # Define all features in the order your model expects them
39
+ # IMPORTANT: This order must match the training data
40
+ EXPECTED_COLUMNS = [
41
+ 'sex', 'race', 'ethnicity', 'marital_status', 'Prior_Mean_Glu',
42
+ 'PT_ELX_GRP_1', 'PT_ELX_GRP_2', 'PT_ELX_GRP_3', 'PT_ELX_GRP_4',
43
+ 'PT_ELX_GRP_5', 'PT_ELX_GRP_6', 'PT_ELX_GRP_7', 'PT_ELX_GRP_8',
44
+ 'PT_ELX_GRP_9', 'PT_ELX_GRP_10', 'PT_ELX_GRP_13', 'PT_ELX_GRP_14',
45
+ 'PT_ELX_GRP_15', 'PT_ELX_GRP_16', 'PT_ELX_GRP_17', 'PT_ELX_GRP_18',
46
+ 'PT_ELX_GRP_19', 'PT_ELX_GRP_20', 'PT_ELX_GRP_21', 'PT_ELX_GRP_22',
47
+ 'PT_ELX_GRP_23', 'PT_ELX_GRP_24', 'PT_ELX_GRP_25', 'PT_ELX_GRP_26',
48
+ 'PT_ELX_GRP_27', 'PT_ELX_GRP_28', 'PT_ELX_GRP_29', 'PT_ELX_GRP_30',
49
+ 'PT_ELX_GRP_31', 'MOF', 'SDOH', 'Gallstone', 'acei_drug', 'statin_drug',
50
+ 'diuretic_drug', 'antiplatelet_drug', 'anticoagulant_drug',
51
+ 'nsaid_drug', 'ppi_drug', 'beta_blokers_drug', 'vasodilators_drug',
52
+ 'caaa_drug', 'ccb_drug', 'paaab_drug', 'age', 'BMI', 'Body_weight',
53
+ 'SBP', 'DBP', 'Mean_AST', 'Mean_ALT', 'Mean_TBIL', 'Mean_ALP',
54
+ 'Mean_Hgb', 'Mean_HCT', 'Mean_Cr', 'Mean_PLT', 'Mean_WBC', 'Mean_BUN',
55
+ 'Mean_AGAP', 'Mean_Protein', 'Smoking', 'eGFR', 'ED_visits', 'LOS',
56
+ 'Prediabetes', 'Alcohol_use', 'Famly_hist_diabetes', 'NAFLD',
57
+ 'Hist_Gesta_diabetes', 'Pregnancy', 'numof_med_visits',
58
+ 'History_AP_necrosis', 'Necrosectomy', 'Steroids_drugs',
59
+ 'oral_contraceptive', 'cholelithiasis', 'acute_cholecystitis',
60
+ 'hypertriglyceridemia'
61
+ ]
62
+
63
+ def predict_diabetes(model_name, sex, race, ethnicity, marital_status, Prior_Mean_Glu,
64
+ PT_ELX_GRP_1, PT_ELX_GRP_2, PT_ELX_GRP_3, PT_ELX_GRP_4,
65
+ PT_ELX_GRP_5, PT_ELX_GRP_6, PT_ELX_GRP_7, PT_ELX_GRP_8,
66
+ PT_ELX_GRP_9, PT_ELX_GRP_10, PT_ELX_GRP_13, PT_ELX_GRP_14,
67
+ PT_ELX_GRP_15, PT_ELX_GRP_16, PT_ELX_GRP_17, PT_ELX_GRP_18,
68
+ PT_ELX_GRP_19, PT_ELX_GRP_20, PT_ELX_GRP_21, PT_ELX_GRP_22,
69
+ PT_ELX_GRP_23, PT_ELX_GRP_24, PT_ELX_GRP_25, PT_ELX_GRP_26,
70
+ PT_ELX_GRP_27, PT_ELX_GRP_28, PT_ELX_GRP_29, PT_ELX_GRP_30,
71
+ PT_ELX_GRP_31, MOF, SDOH, Gallstone, acei_drug, statin_drug,
72
+ diuretic_drug, antiplatelet_drug, anticoagulant_drug,
73
+ nsaid_drug, ppi_drug, beta_blokers_drug, vasodilators_drug,
74
+ caaa_drug, ccb_drug, paaab_drug, age, BMI, Body_weight,
75
+ SBP, DBP, Mean_AST, Mean_ALT, Mean_TBIL, Mean_ALP,
76
+ Mean_Hgb, Mean_HCT, Mean_Cr, Mean_PLT, Mean_WBC, Mean_BUN,
77
+ Mean_AGAP, Mean_Protein, Smoking, eGFR, ED_visits, LOS,
78
+ Prediabetes, Alcohol_use, Famly_hist_diabetes, NAFLD,
79
+ Hist_Gesta_diabetes, Pregnancy, numof_med_visits,
80
+ History_AP_necrosis, Necrosectomy, Steroids_drugs,
81
+ oral_contraceptive, cholelithiasis, acute_cholecystitis,
82
+ hypertriglyceridemia):
83
+
84
+ if not model_name or "No models found" in model_name:
85
+ return "Please select a valid model from the 'models/' directory."
86
+
87
+ model_path = os.path.join(MODEL_DIR, model_name)
88
+ if not os.path.exists(model_path):
89
+ return f"Model file {model_name} not found in {MODEL_DIR}."
90
+
91
+ try:
92
+ model = joblib.load(model_path)
93
+ except Exception as e:
94
+ return f"Error loading model: {e}"
95
+
96
+ # Prepare data for prediction
97
+ input_data = {
98
+ 'sex': SEX_MAP[sex],
99
+ 'race': RACE_MAP[race],
100
+ 'ethnicity': ETHNICITY_MAP[ethnicity],
101
+ 'marital_status': MARITAL_STATUS_MAP[marital_status],
102
+ 'Prior_Mean_Glu': float(Prior_Mean_Glu),
103
+ 'PT_ELX_GRP_1': float(PT_ELX_GRP_1), 'PT_ELX_GRP_2': float(PT_ELX_GRP_2), 'PT_ELX_GRP_3': float(PT_ELX_GRP_3),
104
+ 'PT_ELX_GRP_4': float(PT_ELX_GRP_4), 'PT_ELX_GRP_5': float(PT_ELX_GRP_5), 'PT_ELX_GRP_6': float(PT_ELX_GRP_6),
105
+ 'PT_ELX_GRP_7': float(PT_ELX_GRP_7), 'PT_ELX_GRP_8': float(PT_ELX_GRP_8), 'PT_ELX_GRP_9': float(PT_ELX_GRP_9),
106
+ 'PT_ELX_GRP_10': float(PT_ELX_GRP_10), 'PT_ELX_GRP_13': float(PT_ELX_GRP_13), 'PT_ELX_GRP_14': float(PT_ELX_GRP_14),
107
+ 'PT_ELX_GRP_15': float(PT_ELX_GRP_15), 'PT_ELX_GRP_16': float(PT_ELX_GRP_16), 'PT_ELX_GRP_17': float(PT_ELX_GRP_17),
108
+ 'PT_ELX_GRP_18': float(PT_ELX_GRP_18), 'PT_ELX_GRP_19': float(PT_ELX_GRP_19), 'PT_ELX_GRP_20': float(PT_ELX_GRP_20),
109
+ 'PT_ELX_GRP_21': float(PT_ELX_GRP_21), 'PT_ELX_GRP_22': float(PT_ELX_GRP_22), 'PT_ELX_GRP_23': float(PT_ELX_GRP_23),
110
+ 'PT_ELX_GRP_24': float(PT_ELX_GRP_24), 'PT_ELX_GRP_25': float(PT_ELX_GRP_25), 'PT_ELX_GRP_26': float(PT_ELX_GRP_26),
111
+ 'PT_ELX_GRP_27': float(PT_ELX_GRP_27), 'PT_ELX_GRP_28': float(PT_ELX_GRP_28), 'PT_ELX_GRP_29': float(PT_ELX_GRP_29),
112
+ 'PT_ELX_GRP_30': float(PT_ELX_GRP_30), 'PT_ELX_GRP_31': float(PT_ELX_GRP_31),
113
+ 'MOF': float(MOF), 'SDOH': float(SDOH), 'Gallstone': float(Gallstone),
114
+ 'acei_drug': float(acei_drug), 'statin_drug': float(statin_drug), 'diuretic_drug': float(diuretic_drug),
115
+ 'antiplatelet_drug': float(antiplatelet_drug), 'anticoagulant_drug': float(anticoagulant_drug),
116
+ 'nsaid_drug': float(nsaid_drug), 'ppi_drug': float(ppi_drug), 'beta_blokers_drug': float(beta_blokers_drug),
117
+ 'vasodilators_drug': float(vasodilators_drug), 'caaa_drug': float(caaa_drug), 'ccb_drug': float(ccb_drug),
118
+ 'paaab_drug': float(paaab_drug), 'age': float(age), 'BMI': float(BMI), 'Body_weight': float(Body_weight),
119
+ 'SBP': float(SBP), 'DBP': float(DBP), 'Mean_AST': float(Mean_AST), 'Mean_ALT': float(Mean_ALT),
120
+ 'Mean_TBIL': float(Mean_TBIL), 'Mean_ALP': float(Mean_ALP), 'Mean_Hgb': float(Mean_Hgb),
121
+ 'Mean_HCT': float(Mean_HCT), 'Mean_Cr': float(Mean_Cr), 'Mean_PLT': float(Mean_PLT),
122
+ 'Mean_WBC': float(Mean_WBC), 'Mean_BUN': float(Mean_BUN), 'Mean_AGAP': float(Mean_AGAP),
123
+ 'Mean_Protein': float(Mean_Protein), 'Smoking': float(Smoking), 'eGFR': float(eGFR),
124
+ 'ED_visits': float(ED_visits), 'LOS': float(LOS), 'Prediabetes': float(Prediabetes),
125
+ 'Alcohol_use': float(Alcohol_use), 'Famly_hist_diabetes': float(Famly_hist_diabetes),
126
+ 'NAFLD': float(NAFLD), 'Hist_Gesta_diabetes': float(Hist_Gesta_diabetes), 'Pregnancy': float(Pregnancy),
127
+ 'numof_med_visits': float(numof_med_visits), 'History_AP_necrosis': float(History_AP_necrosis),
128
+ 'Necrosectomy': float(Necrosectomy), 'Steroids_drugs': float(Steroids_drugs),
129
+ 'oral_contraceptive': float(oral_contraceptive), 'cholelithiasis': float(cholelithiasis),
130
+ 'acute_cholecystitis': float(acute_cholecystitis), 'hypertriglyceridemia': float(hypertriglyceridemia)
131
+ }
132
+
133
+ # Create DataFrame in the correct order
134
+ try:
135
+ df = pd.DataFrame([input_data], columns=EXPECTED_COLUMNS)
136
+ except Exception as e:
137
+ return f"Error creating DataFrame: {e}. Check EXPECTED_COLUMNS and input_data keys."
138
+
139
+ # Make prediction
140
+ try:
141
+ prediction = model.predict(df)
142
+ # You might need to access the first element if prediction is an array
143
+ # e.g., result = prediction[0]
144
+ # Also, convert to a more human-readable output
145
+ result = prediction[0]
146
+ if result == 1:
147
+ return "Prediction: Positive for Diabetes"
148
+ else:
149
+ return "Prediction: Negative for Diabetes"
150
+ except Exception as e:
151
+ return f"Error during prediction: {e}"
152
+
153
+ # Define Gradio inputs
154
+ inputs = [
155
+ gr.Dropdown(choices=get_available_models(), label="Select Model"),
156
+ gr.Dropdown(choices=SEX_CHOICES, label="Sex"),
157
+ gr.Dropdown(choices=RACE_CHOICES, label="Race"),
158
+ gr.Dropdown(choices=ETHNICITY_CHOICES, label="Ethnicity"),
159
+ gr.Dropdown(choices=MARITAL_STATUS_CHOICES, label="Marital Status"),
160
+ gr.Number(label="Prior Mean Glu"),
161
+ gr.Number(label="PT_ELX_GRP_1"), gr.Number(label="PT_ELX_GRP_2"), gr.Number(label="PT_ELX_GRP_3"),
162
+ gr.Number(label="PT_ELX_GRP_4"), gr.Number(label="PT_ELX_GRP_5"), gr.Number(label="PT_ELX_GRP_6"),
163
+ gr.Number(label="PT_ELX_GRP_7"), gr.Number(label="PT_ELX_GRP_8"), gr.Number(label="PT_ELX_GRP_9"),
164
+ gr.Number(label="PT_ELX_GRP_10"), gr.Number(label="PT_ELX_GRP_13"), gr.Number(label="PT_ELX_GRP_14"),
165
+ gr.Number(label="PT_ELX_GRP_15"), gr.Number(label="PT_ELX_GRP_16"), gr.Number(label="PT_ELX_GRP_17"),
166
+ gr.Number(label="PT_ELX_GRP_18"), gr.Number(label="PT_ELX_GRP_19"), gr.Number(label="PT_ELX_GRP_20"),
167
+ gr.Number(label="PT_ELX_GRP_21"), gr.Number(label="PT_ELX_GRP_22"), gr.Number(label="PT_ELX_GRP_23"),
168
+ gr.Number(label="PT_ELX_GRP_24"), gr.Number(label="PT_ELX_GRP_25"), gr.Number(label="PT_ELX_GRP_26"),
169
+ gr.Number(label="PT_ELX_GRP_27"), gr.Number(label="PT_ELX_GRP_28"), gr.Number(label="PT_ELX_GRP_29"),
170
+ gr.Number(label="PT_ELX_GRP_30"), gr.Number(label="PT_ELX_GRP_31"),
171
+ gr.Number(label="MOF"), gr.Number(label="SDOH"), gr.Number(label="Gallstone"),
172
+ gr.Number(label="ACE Inhibitor Drug"), gr.Number(label="Statin Drug"), gr.Number(label="Diuretic Drug"),
173
+ gr.Number(label="Antiplatelet Drug"), gr.Number(label="Anticoagulant Drug"),
174
+ gr.Number(label="NSAID Drug"), gr.Number(label="PPI Drug"), gr.Number(label="Beta Blockers Drug"),
175
+ gr.Number(label="Vasodilators Drug"), gr.Number(label="CAAA Drug"), gr.Number(label="CCB Drug"),
176
+ gr.Number(label="PAAAB Drug"), gr.Number(label="Age"), gr.Number(label="BMI"),
177
+ gr.Number(label="Body Weight (kg)"), gr.Number(label="SBP (Systolic Blood Pressure)"),
178
+ gr.Number(label="DBP (Diastolic Blood Pressure)"), gr.Number(label="Mean AST"), gr.Number(label="Mean ALT"),
179
+ gr.Number(label="Mean TBIL"), gr.Number(label="Mean ALP"), gr.Number(label="Mean Hgb"),
180
+ gr.Number(label="Mean HCT"), gr.Number(label="Mean Cr"), gr.Number(label="Mean PLT"),
181
+ gr.Number(label="Mean WBC"), gr.Number(label="Mean BUN"), gr.Number(label="Mean AGAP"),
182
+ gr.Number(label="Mean Protein"), gr.Number(label="Smoking"), gr.Number(label="eGFR"),
183
+ gr.Number(label="ED Visits"), gr.Number(label="LOS (Length of Stay)"), gr.Number(label="Prediabetes"),
184
+ gr.Number(label="Alcohol Use"), gr.Number(label="Family History of Diabetes"),
185
+ gr.Number(label="NAFLD"), gr.Number(label="History of Gestational Diabetes"),
186
+ gr.Number(label="Pregnancy"), gr.Number(label="Number of Medical Visits"),
187
+ gr.Number(label="History AP Necrosis"), gr.Number(label="Necrosectomy"),
188
+ gr.Number(label="Steroids Drugs"), gr.Number(label="Oral Contraceptive"),
189
+ gr.Number(label="Cholelithiasis"), gr.Number(label="Acute Cholecystitis"),
190
+ gr.Number(label="Hypertriglyceridemia")
191
+ ]
192
+
193
+ # Define output
194
+ output = gr.Textbox(label="Prediction Result")
195
+
196
+ # Create and launch the Gradio interface
197
+ iface = gr.Interface(
198
+ fn=predict_diabetes,
199
+ inputs=inputs,
200
+ outputs=output,
201
+ title="Diabetes Prediction",
202
+ description="Enter patient data to predict diabetes. Ensure your models are in the 'models' directory.",
203
+ allow_flagging='never'
204
+ )
205
+
206
+ if __name__ == "__main__":
207
+ iface.launch()
models/README.md ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
 
1
+ # Models Directory
2
+
3
+ Please place your trained scikit-learn model files (ending with `.joblib`) in this directory.
4
+
5
+ The Gradio application (`app.py`) will automatically detect these models and make them available for selection in the UI.
6
+
7
+ For example, if you have a model saved as `my_diabetes_model.joblib`, you would place it here:
8
+ `models/my_diabetes_model.joblib`
requirements.txt ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
 
1
+ scikit-learn
2
+ pandas
3
+ joblib
4
+ gradio
5
+ tabpfn