criticalDanger
commited on
Commit
•
1753d99
1
Parent(s):
fe43959
Create app.py
Browse files
app.py
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import gradio as gr
|
2 |
+
import numpy as np
|
3 |
+
import pickle
|
4 |
+
|
5 |
+
# Load the trained model
|
6 |
+
with open('asthma_disease_model.pkl', 'rb') as file:
|
7 |
+
model = pickle.load(file)
|
8 |
+
|
9 |
+
# Define the prediction function
|
10 |
+
def predict_heart_disease(Age, Gender, BMI, Smoking, PhysicalActivity, DietQuality, SleepQuality, PollutionExposure, PollenExposure, DustExposure, PetAllergy, FamilyHistoryAsthma, HistoryOfAllergies, Eczema, HayFever, GastroesophagealReflux, Wheezing, ShortnessOfBreath, ChestTightness, Coughing, NighttimeSymptoms, ExerciseInduced):
|
11 |
+
male = 1 if male == "Male" else 0
|
12 |
+
currentSmoker = 1 if currentSmoker == "Yes" else 0
|
13 |
+
BPMeds = 1 if BPMeds == "Yes" else 0
|
14 |
+
prevalentStroke = 1 if prevalentStroke == "Yes" else 0
|
15 |
+
prevalentHyp = 1 if prevalentHyp == "Yes" else 0
|
16 |
+
diabetes = 1 if diabetes == "Yes" else 0
|
17 |
+
input_data = np.array([[male, age, currentSmoker, cigsPerDay, BPMeds, prevalentStroke, prevalentHyp, diabetes, BMI]])
|
18 |
+
prediction = model.predict(input_data)
|
19 |
+
return 'Heart Disease' if prediction[0] == 1 else 'No Heart Disease'
|
20 |
+
|
21 |
+
# Define the input components
|
22 |
+
inputs = [
|
23 |
+
gr.Number(label="Age"),
|
24 |
+
gr.Radio(choices=["Male","Female"], label="Sex")
|
25 |
+
gr.Number(value=float, label="What is your BMI?"),
|
26 |
+
gr.Radio(chpices=["Yes","No"], label="Do you smoke?"),
|
27 |
+
gr.Slider(label="Rate your physical activeness", minimum=0, maximum=10, step=0.1),
|
28 |
+
gr.Slider(label="Rate your diet quality", minimum=0, maximum=10, step=1),
|
29 |
+
gr.Slider(label="Rate your sleep quality", minimum=4, maximum=10, step=1),
|
30 |
+
gr.Slider(label="Rate your pollution exposure", minimum=0, maximum=10, step=1),
|
31 |
+
gr.Slider(label="Rate your pollen exposure", minimum=0, maximum=10, step=1),
|
32 |
+
gr.Slider(label="Rate your dust exposure", minimum=0, maximum=10, step=1),
|
33 |
+
gr.Checkbox(label="Pet Allergy"),
|
34 |
+
gr.Checkbox(label="Family History of Asthma"),
|
35 |
+
gr.Checkbox(label="Do you have history of allergies?"),
|
36 |
+
gr.Checkbox(label="Eczema"),
|
37 |
+
gr.Checkbox(label="Hay fever"),
|
38 |
+
gr.Checkbox(label="Do you have Gastroesophageal Reflux?"),
|
39 |
+
gr.Checkbox(label="Do you wheeze?"),
|
40 |
+
gr.Checkbox(label="Do you feel shortness of breath?"),
|
41 |
+
gr.Checkbox(label="Do you feel chest tightness?"),
|
42 |
+
gr.Checkbox(label="Do you Cough very often?"),
|
43 |
+
gr.Checkbox(label="Do you these symptoms occur in the night time?"),
|
44 |
+
gr.Checkbox(label="Do you these symptoms occur during exercise?"),
|
45 |
+
|
46 |
+
]
|
47 |
+
|
48 |
+
# Define the output component
|
49 |
+
outputs = gr.Textbox(label="Prediction")
|
50 |
+
|
51 |
+
# Create and launch the Gradio interface
|
52 |
+
gr.Interface(fn=predict_heart_disease, inputs=inputs, outputs=outputs).launch()
|