Arittra-Bag commited on
Commit
8b8a799
1 Parent(s): 97a21d9

Initial commit

Browse files
Files changed (4) hide show
  1. app.py +157 -0
  2. disease_prediction_model.pkl +0 -0
  3. label_encoder.pkl +0 -0
  4. requirements.txt +3 -0
app.py ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import pandas as pd
3
+ import joblib
4
+
5
+ # Load the model and label encoder
6
+ model = joblib.load('disease_prediction_model.pkl')
7
+ label_encoder = joblib.load('label_encoder.pkl')
8
+
9
+ # Define a function for predictions
10
+ def predict_disease(
11
+ itching, skin_rash, nodal_skin_eruptions, continuous_sneezing, shivering,
12
+ chills, joint_pain, stomach_pain, acidity, ulcers_on_tongue,
13
+ muscle_wasting, vomiting, burning_micturition, spotting_urination, fatigue,
14
+ weight_gain, anxiety, cold_hands_and_feets, mood_swings, weight_loss,
15
+ restlessness, lethargy, patches_in_throat, irregular_sugar_level, cough,
16
+ high_fever, sunken_eyes, breathlessness, sweating, dehydration,
17
+ indigestion, headache, yellowish_skin, dark_urine, nausea, loss_of_appetite,
18
+ pain_behind_the_eyes, back_pain, constipation, abdominal_pain, diarrhoea,
19
+ mild_fever, yellow_urine, yellowing_of_eyes, acute_liver_failure, fluid_overload,
20
+ swelling_of_stomach, swelled_lymph_nodes, malaise, blurred_and_distorted_vision,
21
+ phlegm, throat_irritation, redness_of_eyes, sinus_pressure, runny_nose,
22
+ congestion, chest_pain, weakness_in_limbs, fast_heart_rate, pain_during_bowel_movements,
23
+ pain_in_anal_region, bloody_stool, irritation_in_anus, neck_pain, dizziness,
24
+ cramps, bruising, obesity, swollen_legs, swollen_blood_vessels, puffy_face_and_eyes,
25
+ enlarged_thyroid, brittle_nails, swollen_extremeties, excessive_hunger, extra_marital_contacts,
26
+ drying_and_tingling_lips, slurred_speech, knee_pain, hip_joint_pain, muscle_weakness,
27
+ stiff_neck, swelling_joints, movement_stiffness, spinning_movements, loss_of_balance,
28
+ unsteadiness, weakness_of_one_body_side, loss_of_smell, bladder_discomfort,
29
+ foul_smell_of_urine, continuous_feel_of_urine, passage_of_gases, internal_itching,
30
+ toxic_look_typhos, depression, irritability, muscle_pain, altered_sensorium,
31
+ red_spots_over_body, belly_pain, abnormal_menstruation, dischromic_patches,
32
+ watering_from_eyes, increased_appetite, polyuria, family_history, mucoid_sputum,
33
+ rusty_sputum, lack_of_concentration, visual_disturbances, receiving_blood_transfusion,
34
+ receiving_unsterile_injections, coma, stomach_bleeding, distention_of_abdomen,
35
+ history_of_alcohol_consumption, fluid_overload_1, blood_in_sputum, prominent_veins_on_calf,
36
+ palpitations, painful_walking, pus_filled_pimples, blackheads, scurring,
37
+ skin_peeling, silver_like_dusting, small_dents_in_nails, inflammatory_nails, blister,
38
+ red_sore_around_nose, yellow_crust_ooze
39
+ ):
40
+ # Create a DataFrame from the inputs
41
+ input_data = pd.DataFrame([[
42
+ itching, skin_rash, nodal_skin_eruptions, continuous_sneezing, shivering,
43
+ chills, joint_pain, stomach_pain, acidity, ulcers_on_tongue,
44
+ muscle_wasting, vomiting, burning_micturition, spotting_urination, fatigue,
45
+ weight_gain, anxiety, cold_hands_and_feets, mood_swings, weight_loss,
46
+ restlessness, lethargy, patches_in_throat, irregular_sugar_level, cough,
47
+ high_fever, sunken_eyes, breathlessness, sweating, dehydration,
48
+ indigestion, headache, yellowish_skin, dark_urine, nausea, loss_of_appetite,
49
+ pain_behind_the_eyes, back_pain, constipation, abdominal_pain, diarrhoea,
50
+ mild_fever, yellow_urine, yellowing_of_eyes, acute_liver_failure, fluid_overload,
51
+ swelling_of_stomach, swelled_lymph_nodes, malaise, blurred_and_distorted_vision,
52
+ phlegm, throat_irritation, redness_of_eyes, sinus_pressure, runny_nose,
53
+ congestion, chest_pain, weakness_in_limbs, fast_heart_rate, pain_during_bowel_movements,
54
+ pain_in_anal_region, bloody_stool, irritation_in_anus, neck_pain, dizziness,
55
+ cramps, bruising, obesity, swollen_legs, swollen_blood_vessels, puffy_face_and_eyes,
56
+ enlarged_thyroid, brittle_nails, swollen_extremeties, excessive_hunger, extra_marital_contacts,
57
+ drying_and_tingling_lips, slurred_speech, knee_pain, hip_joint_pain, muscle_weakness,
58
+ stiff_neck, swelling_joints, movement_stiffness, spinning_movements, loss_of_balance,
59
+ unsteadiness, weakness_of_one_body_side, loss_of_smell, bladder_discomfort,
60
+ foul_smell_of_urine, continuous_feel_of_urine, passage_of_gases, internal_itching,
61
+ toxic_look_typhos, depression, irritability, muscle_pain, altered_sensorium,
62
+ red_spots_over_body, belly_pain, abnormal_menstruation, dischromic_patches,
63
+ watering_from_eyes, increased_appetite, polyuria, family_history, mucoid_sputum,
64
+ rusty_sputum, lack_of_concentration, visual_disturbances, receiving_blood_transfusion,
65
+ receiving_unsterile_injections, coma, stomach_bleeding, distention_of_abdomen,
66
+ history_of_alcohol_consumption, fluid_overload_1, blood_in_sputum, prominent_veins_on_calf,
67
+ palpitations, painful_walking, pus_filled_pimples, blackheads, scurring,
68
+ skin_peeling, silver_like_dusting, small_dents_in_nails, inflammatory_nails, blister,
69
+ red_sore_around_nose, yellow_crust_ooze
70
+ ]], columns=model.feature_names_in_)
71
+
72
+ # Predict the disease
73
+ prediction = model.predict(input_data)
74
+ predicted_disease = label_encoder.inverse_transform(prediction)[0]
75
+ return predicted_disease
76
+
77
+ # Define the inputs for Gradio
78
+ inputs = [
79
+ gr.Checkbox(label='itching'), gr.Checkbox(label='skin_rash'),
80
+ gr.Checkbox(label='nodal_skin_eruptions'), gr.Checkbox(label='continuous_sneezing'),
81
+ gr.Checkbox(label='shivering'), gr.Checkbox(label='chills'),
82
+ gr.Checkbox(label='joint_pain'), gr.Checkbox(label='stomach_pain'),
83
+ gr.Checkbox(label='acidity'), gr.Checkbox(label='ulcers_on_tongue'),
84
+ gr.Checkbox(label='muscle_wasting'), gr.Checkbox(label='vomiting'),
85
+ gr.Checkbox(label='burning_micturition'), gr.Checkbox(label='spotting_urination'),
86
+ gr.Checkbox(label='fatigue'), gr.Checkbox(label='weight_gain'),
87
+ gr.Checkbox(label='anxiety'), gr.Checkbox(label='cold_hands_and_feets'),
88
+ gr.Checkbox(label='mood_swings'), gr.Checkbox(label='weight_loss'),
89
+ gr.Checkbox(label='restlessness'), gr.Checkbox(label='lethargy'),
90
+ gr.Checkbox(label='patches_in_throat'), gr.Checkbox(label='irregular_sugar_level'),
91
+ gr.Checkbox(label='cough'), gr.Checkbox(label='high_fever'),
92
+ gr.Checkbox(label='sunken_eyes'), gr.Checkbox(label='breathlessness'),
93
+ gr.Checkbox(label='sweating'), gr.Checkbox(label='dehydration'),
94
+ gr.Checkbox(label='indigestion'), gr.Checkbox(label='headache'),
95
+ gr.Checkbox(label='yellowish_skin'), gr.Checkbox(label='dark_urine'),
96
+ gr.Checkbox(label='nausea'), gr.Checkbox(label='loss_of_appetite'),
97
+ gr.Checkbox(label='pain_behind_the_eyes'), gr.Checkbox(label='back_pain'),
98
+ gr.Checkbox(label='constipation'), gr.Checkbox(label='abdominal_pain'),
99
+ gr.Checkbox(label='diarrhoea'), gr.Checkbox(label='mild_fever'),
100
+ gr.Checkbox(label='yellow_urine'), gr.Checkbox(label='yellowing_of_eyes'),
101
+ gr.Checkbox(label='acute_liver_failure'), gr.Checkbox(label='fluid_overload'),
102
+ gr.Checkbox(label='swelling_of_stomach'), gr.Checkbox(label='swelled_lymph_nodes'),
103
+ gr.Checkbox(label='malaise'), gr.Checkbox(label='blurred_and_distorted_vision'),
104
+ gr.Checkbox(label='phlegm'), gr.Checkbox(label='throat_irritation'),
105
+ gr.Checkbox(label='redness_of_eyes'), gr.Checkbox(label='sinus_pressure'),
106
+ gr.Checkbox(label='runny_nose'), gr.Checkbox(label='congestion'),
107
+ gr.Checkbox(label='chest_pain'), gr.Checkbox(label='weakness_in_limbs'),
108
+ gr.Checkbox(label='fast_heart_rate'), gr.Checkbox(label='pain_during_bowel_movements'),
109
+ gr.Checkbox(label='pain_in_anal_region'), gr.Checkbox(label='bloody_stool'),
110
+ gr.Checkbox(label='irritation_in_anus'), gr.Checkbox(label='neck_pain'),
111
+ gr.Checkbox(label='dizziness'), gr.Checkbox(label='cramps'),
112
+ gr.Checkbox(label='bruising'), gr.Checkbox(label='obesity'),
113
+ gr.Checkbox(label='swollen_legs'), gr.Checkbox(label='swollen_blood_vessels'),
114
+ gr.Checkbox(label='puffy_face_and_eyes'), gr.Checkbox(label='enlarged_thyroid'),
115
+ gr.Checkbox(label='brittle_nails'), gr.Checkbox(label='swollen_extremeties'),
116
+ gr.Checkbox(label='excessive_hunger'), gr.Checkbox(label='extra_marital_contacts'),
117
+ gr.Checkbox(label='drying_and_tingling_lips'), gr.Checkbox(label='slurred_speech'),
118
+ gr.Checkbox(label='knee_pain'), gr.Checkbox(label='hip_joint_pain'),
119
+ gr.Checkbox(label='muscle_weakness'), gr.Checkbox(label='stiff_neck'),
120
+ gr.Checkbox(label='swelling_joints'), gr.Checkbox(label='movement_stiffness'),
121
+ gr.Checkbox(label='spinning_movements'), gr.Checkbox(label='loss_of_balance'),
122
+ gr.Checkbox(label='unsteadiness'), gr.Checkbox(label='weakness_of_one_body_side'),
123
+ gr.Checkbox(label='loss_of_smell'), gr.Checkbox(label='bladder_discomfort'),
124
+ gr.Checkbox(label='foul_smell_of_urine'), gr.Checkbox(label='continuous_feel_of_urine'),
125
+ gr.Checkbox(label='passage_of_gases'), gr.Checkbox(label='internal_itching'),
126
+ gr.Checkbox(label='toxic_look_typhos'), gr.Checkbox(label='depression'),
127
+ gr.Checkbox(label='irritability'), gr.Checkbox(label='muscle_pain'),
128
+ gr.Checkbox(label='altered_sensorium'), gr.Checkbox(label='red_spots_over_body'),
129
+ gr.Checkbox(label='belly_pain'), gr.Checkbox(label='abnormal_menstruation'),
130
+ gr.Checkbox(label='dischromic_patches'), gr.Checkbox(label='watering_from_eyes'),
131
+ gr.Checkbox(label='increased_appetite'), gr.Checkbox(label='polyuria'),
132
+ gr.Checkbox(label='family_history'), gr.Checkbox(label='mucoid_sputum'),
133
+ gr.Checkbox(label='rusty_sputum'), gr.Checkbox(label='lack_of_concentration'),
134
+ gr.Checkbox(label='visual_disturbances'), gr.Checkbox(label='receiving_blood_transfusion'),
135
+ gr.Checkbox(label='receiving_unsterile_injections'), gr.Checkbox(label='coma'),
136
+ gr.Checkbox(label='stomach_bleeding'), gr.Checkbox(label='distention_of_abdomen'),
137
+ gr.Checkbox(label='history_of_alcohol_consumption'), gr.Checkbox(label='fluid_overload_1'),
138
+ gr.Checkbox(label='blood_in_sputum'), gr.Checkbox(label='prominent_veins_on_calf'),
139
+ gr.Checkbox(label='palpitations'), gr.Checkbox(label='painful_walking'),
140
+ gr.Checkbox(label='pus_filled_pimples'), gr.Checkbox(label='blackheads'),
141
+ gr.Checkbox(label='scurring'), gr.Checkbox(label='skin_peeling'),
142
+ gr.Checkbox(label='silver_like_dusting'), gr.Checkbox(label='small_dents_in_nails'),
143
+ gr.Checkbox(label='inflammatory_nails'), gr.Checkbox(label='blister'),
144
+ gr.Checkbox(label='red_sore_around_nose'), gr.Checkbox(label='yellow_crust_ooze')
145
+ ]
146
+
147
+ # Create the Gradio interface
148
+ interface = gr.Interface(
149
+ fn=predict_disease,
150
+ inputs=inputs,
151
+ outputs='text',
152
+ title='Disease Prediction Bot',
153
+ description='Enter symptoms to get a disease prediction.'
154
+ )
155
+
156
+ # Launch the Gradio interface
157
+ interface.launch()
disease_prediction_model.pkl ADDED
Binary file (47.7 kB). View file
 
label_encoder.pkl ADDED
Binary file (1.34 kB). View file
 
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ gradio
2
+ pandas
3
+ joblib