File size: 3,599 Bytes
1753d99
 
 
 
 
 
 
 
 
 
2cd231c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1753d99
a63b07a
1753d99
 
 
9cd1ddc
f20ad67
0c0c9cb
2cd231c
 
1753d99
 
 
 
 
2cd231c
 
1753d99
a40d01f
 
1753d99
 
 
 
 
 
 
 
 
 
 
 
 
f518306
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1753d99
f518306
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import gradio as gr
import numpy as np
import pickle

# Load the trained model
with open('asthma_disease_model.pkl', 'rb') as file:
    model = pickle.load(file)

# Define the prediction function
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):
    Gender = 0 if Gender == "Male" else 1
    Smoking = 1 if Smoking else 0
    PetAllergy = 1 if PetAllergy else 0
    FamilyHistoryAsthma = 1 if FamilyHistoryAsthma else 0
    HistoryOfAllergies = 1 if HistoryOfAllergies else 0
    Eczema = 1 if Eczema else 0
    HayFever = 1 if HayFever else 0
    GastroesophagealReflux = 1 if GastroesophagealReflux else 0
    Wheezing = 1 if Wheezing else 0
    ShortnessOfBreath = 1 if ShortnessOfBreath else 0
    ChestTightness = 1 if ChestTightness else 0
    Coughing = 1 if Coughing else 0
    NighttimeSymptoms = 1 if NighttimeSymptoms else 0
    ExerciseInduced = 1 if ExerciseInduced else 0
    input_data = np.array([[Age, Gender, BMI, Smoking, PhysicalActivity, DietQuality, SleepQuality, PollutionExposure, PollenExposure, DustExposure, PetAllergy, FamilyHistoryAsthma, HistoryOfAllergies, Eczema, HayFever, GastroesophagealReflux, Wheezing, ShortnessOfBreath, ChestTightness, Coughing, NighttimeSymptoms, ExerciseInduced]])
    prediction = model.predict(input_data)
    return 'You have a significant chance of having asthma.' if prediction[0] == 1 else 'You possibly do not have asthma.'

# Define the input components
inputs = [
    gr.Number(label="Age", minimum=5, maximum=80),
    gr.Radio(choices=["Male","Female"], label="Sex"),
    gr.Number(value=float, label="What is your BMI?", minimum=13, maximum=40),
    gr.Checkbox(label="Do you smoke?"),
    gr.Slider(label="Rate your physical activeness", minimum=0, maximum=10, step=1),
    gr.Slider(label="Rate your diet quality", minimum=0, maximum=10, step=1),
    gr.Slider(label="Rate your sleep quality", minimum=4, maximum=10, step=1),
    gr.Slider(label="Rate your pollution exposure", minimum=0, maximum=10, step=1),
    gr.Slider(label="Rate your pollen exposure", minimum=0, maximum=10, step=1),
    gr.Slider(label="Rate your dust exposure", minimum=0, maximum=10, step=1),
    gr.Checkbox(label="Do you have Pet Allergy?"),
    gr.Checkbox(label="Does your family have a history of Asthma"),
    gr.Checkbox(label="Do you have history of allergies?"),
    gr.Checkbox(label="Do you have Eczema?"),
    gr.Checkbox(label="Do you have Hay fever?"),
    gr.Checkbox(label="Do you have Gastroesophageal Reflux?"),
    gr.Checkbox(label="Do you wheeze?"),
    gr.Checkbox(label="Do you feel shortness of breath?"),
    gr.Checkbox(label="Do you feel chest tightness?"),
    gr.Checkbox(label="Do you Cough very often?"),
    gr.Checkbox(label="Do you these symptoms occur in the night time?"),
    gr.Checkbox(label="Do you these symptoms occur during exercise?"),
    
]

# Define the output component
outputs = gr.Textbox(label="Prediction")

# Define custom css for the interface
custom_css = """
body {
    background-color: white;
    colour: black;
}
.gradio-container {
    background-color: white;
}
.gradio-interface input, .gradio-interface select {
    background-color: #f0f0f0;
    color: black;
}
"""

# Create and launch the Gradio interface
gr.Interface(fn=predict_heart_disease, inputs=inputs, outputs=outputs, css=custom_css).launch()