DHEIVER Dikshant09 commited on
Commit
8f8aa9e
·
0 Parent(s):

Duplicate from Dikshant09/disease-prediction-api

Browse files

Co-authored-by: Dikshant <Dikshant09@users.noreply.huggingface.co>

.gitattributes ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ *.7z filter=lfs diff=lfs merge=lfs -text
2
+ *.arrow filter=lfs diff=lfs merge=lfs -text
3
+ *.bin filter=lfs diff=lfs merge=lfs -text
4
+ *.bz2 filter=lfs diff=lfs merge=lfs -text
5
+ *.ckpt filter=lfs diff=lfs merge=lfs -text
6
+ *.ftz filter=lfs diff=lfs merge=lfs -text
7
+ *.gz filter=lfs diff=lfs merge=lfs -text
8
+ *.h5 filter=lfs diff=lfs merge=lfs -text
9
+ *.joblib filter=lfs diff=lfs merge=lfs -text
10
+ *.lfs.* filter=lfs diff=lfs merge=lfs -text
11
+ *.mlmodel filter=lfs diff=lfs merge=lfs -text
12
+ *.model filter=lfs diff=lfs merge=lfs -text
13
+ *.msgpack filter=lfs diff=lfs merge=lfs -text
14
+ *.npy filter=lfs diff=lfs merge=lfs -text
15
+ *.npz filter=lfs diff=lfs merge=lfs -text
16
+ *.onnx filter=lfs diff=lfs merge=lfs -text
17
+ *.ot filter=lfs diff=lfs merge=lfs -text
18
+ *.parquet filter=lfs diff=lfs merge=lfs -text
19
+ *.pb filter=lfs diff=lfs merge=lfs -text
20
+ *.pickle filter=lfs diff=lfs merge=lfs -text
21
+ *.pkl filter=lfs diff=lfs merge=lfs -text
22
+ *.pt filter=lfs diff=lfs merge=lfs -text
23
+ *.pth filter=lfs diff=lfs merge=lfs -text
24
+ *.rar filter=lfs diff=lfs merge=lfs -text
25
+ *.safetensors filter=lfs diff=lfs merge=lfs -text
26
+ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
27
+ *.tar.* filter=lfs diff=lfs merge=lfs -text
28
+ *.tflite filter=lfs diff=lfs merge=lfs -text
29
+ *.tgz filter=lfs diff=lfs merge=lfs -text
30
+ *.wasm filter=lfs diff=lfs merge=lfs -text
31
+ *.xz filter=lfs diff=lfs merge=lfs -text
32
+ *.zip filter=lfs diff=lfs merge=lfs -text
33
+ *.zst filter=lfs diff=lfs merge=lfs -text
34
+ *tfevents* filter=lfs diff=lfs merge=lfs -text
README.md ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ title: Disease Prediction Api
3
+ emoji: 📊
4
+ colorFrom: indigo
5
+ colorTo: green
6
+ sdk: gradio
7
+ sdk_version: 3.19.1
8
+ app_file: app.py
9
+ pinned: false
10
+ license: mit
11
+ duplicated_from: Dikshant09/disease-prediction-api
12
+ ---
13
+
14
+ Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
app.py ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Importing libraries
2
+ import numpy as np
3
+ from scipy.stats import mode
4
+ import warnings
5
+ import pickle
6
+
7
+ import gradio as gr
8
+
9
+ # Ignoring Warnings
10
+ warnings.filterwarnings("ignore")
11
+
12
+ # Loading Saved Models
13
+ model = pickle.load(open('saved_final_rf_model.pkl', 'rb'))
14
+
15
+ data_dict = {'symptom_index': {'Itching': 0, 'Skin Rash': 1, 'Nodal Skin Eruptions': 2, 'Continuous Sneezing': 3, 'Shivering': 4, 'Chills': 5, 'Joint Pain': 6, 'Stomach Pain': 7, 'Acidity': 8, 'Ulcers On Tongue': 9, 'Muscle Wasting': 10, 'Vomiting': 11, 'Burning Micturition': 12, 'Spotting urination': 13, 'Fatigue': 14, 'Weight Gain': 15, 'Anxiety': 16, 'Cold Hands And Feets': 17, 'Mood Swings': 18, 'Weight Loss': 19, 'Restlessness': 20, 'Lethargy': 21, 'Patches In Throat': 22, 'Irregular Sugar Level': 23, 'Cough': 24, 'High Fever': 25, 'Sunken Eyes': 26, 'Breathlessness': 27, 'Sweating': 28, 'Dehydration': 29, 'Indigestion': 30, 'Headache': 31, 'Yellowish Skin': 32, 'Dark Urine': 33, 'Nausea': 34, 'Loss Of Appetite': 35, 'Pain Behind The Eyes': 36, 'Back Pain': 37, 'Constipation': 38, 'Abdominal Pain': 39, 'Diarrhoea': 40, 'Mild Fever': 41, 'Yellow Urine': 42, 'Yellowing Of Eyes': 43, 'Acute Liver Failure': 44, 'Fluid Overload': 45, 'Swelling Of Stomach': 46, 'Swelled Lymph Nodes': 47, 'Malaise': 48, 'Blurred And Distorted Vision': 49, 'Phlegm': 50, 'Throat Irritation': 51, 'Redness Of Eyes': 52, 'Sinus Pressure': 53, 'Runny Nose': 54, 'Congestion': 55, 'Chest Pain': 56, 'Weakness In Limbs': 57, 'Fast Heart Rate': 58, 'Pain During Bowel Movements': 59, 'Pain In Anal Region': 60, 'Bloody Stool': 61, 'Irritation In Anus': 62, 'Neck Pain': 63, 'Dizziness': 64, 'Cramps': 65, 'Bruising': 66, 'Obesity': 67, 'Swollen Legs': 68, 'Swollen Blood Vessels': 69, 'Puffy Face And Eyes': 70, 'Enlarged Thyroid': 71, 'Brittle Nails': 72, 'Swollen Extremeties': 73, 'Excessive Hunger': 74, 'Extra Marital Contacts': 75, 'Drying And Tingling Lips': 76, 'Slurred Speech': 77, 'Knee Pain': 78, 'Hip Joint Pain': 79, 'Muscle Weakness': 80, 'Stiff Neck': 81, 'Swelling Joints': 82, 'Movement Stiffness': 83, 'Spinning Movements': 84, 'Loss Of Balance': 85, 'Unsteadiness': 86, 'Weakness Of One Body Side': 87, 'Loss Of Smell': 88, 'Bladder Discomfort': 89, 'Foul Smell Of urine': 90, 'Continuous Feel Of Urine': 91, 'Passage Of Gases': 92, 'Internal Itching': 93, 'Toxic Look (typhos)': 94, 'Depression': 95, 'Irritability': 96, 'Muscle Pain': 97, 'Altered Sensorium': 98, 'Red Spots Over Body': 99, 'Belly Pain': 100, 'Abnormal Menstruation': 101, 'Dischromic Patches': 102, 'Watering From Eyes': 103, 'Increased Appetite': 104, 'Polyuria': 105, 'Family History': 106, 'Mucoid Sputum': 107, 'Rusty Sputum': 108, 'Lack Of Concentration': 109, 'Visual Disturbances': 110, 'Receiving Blood Transfusion': 111, 'Receiving Unsterile Injections': 112, 'Coma': 113, 'Stomach Bleeding': 114, 'Distention Of Abdomen': 115, 'History Of Alcohol Consumption': 116, 'Fluid Overload.1': 117, 'Blood In Sputum': 118, 'Prominent Veins On Calf': 119, 'Palpitations': 120, 'Painful Walking': 121, 'Pus Filled Pimples': 122, 'Blackheads': 123, 'Scurring': 124, 'Skin Peeling': 125, 'Silver Like Dusting': 126, 'Small Dents In Nails': 127, 'Inflammatory Nails': 128, 'Blister': 129, 'Red Sore Around Nose': 130, 'Yellow Crust Ooze': 131},
16
+ 'predictions_classes': ['(vertigo) Paroymsal Positional Vertigo', 'AIDS', 'Acne',
17
+ 'Alcoholic hepatitis', 'Allergy', 'Arthritis', 'Bronchial Asthma',
18
+ 'Cervical spondylosis', 'Chicken pox', 'Chronic cholestasis',
19
+ 'Common Cold', 'Dengue', 'Diabetes ',
20
+ 'Dimorphic hemmorhoids(piles)', 'Drug Reaction',
21
+ 'Fungal infection', 'GERD', 'Gastroenteritis', 'Heart attack',
22
+ 'Hepatitis B', 'Hepatitis C', 'Hepatitis D', 'Hepatitis E',
23
+ 'Hypertension ', 'Hyperthyroidism', 'Hypoglycemia',
24
+ 'Hypothyroidism', 'Impetigo', 'Jaundice', 'Malaria', 'Migraine',
25
+ 'Osteoarthristis', 'Paralysis (brain hemorrhage)',
26
+ 'Peptic ulcer diseae', 'Pneumonia', 'Psoriasis', 'Tuberculosis',
27
+ 'Typhoid', 'Urinary tract infection', 'Varicose veins',
28
+ 'hepatitis A']}
29
+
30
+ def predictDisease(symptoms):
31
+ symptoms = symptoms.split(",")
32
+
33
+ # creating input data for the models
34
+ input_data = [0] * len(data_dict["symptom_index"])
35
+ for symptom in symptoms:
36
+ index = data_dict["symptom_index"][symptom]
37
+ input_data[index] = 1
38
+
39
+ # reshaping the input data and converting it
40
+ # into suitable format for model predictions
41
+ input_data = np.array(input_data).reshape(1,-1)
42
+
43
+ # generating individual outputs
44
+ prediction = data_dict["predictions_classes"][model.predict(input_data)[0]]
45
+
46
+ # making final prediction by taking mode of all predictions
47
+ final_prediction = mode([prediction])[0][0]
48
+ return final_prediction
49
+
50
+ # Input: Systoms
51
+ # Output: Disease
52
+ def makePrediction(Enter_Symptom):
53
+ return predictDisease(Enter_Symptom)
54
+
55
+ iface = gr.Interface(fn = makePrediction, inputs = "text", outputs = "text")
56
+ iface.launch()
requirements.txt ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ certifi==2022.12.7
2
+ charset-normalizer==3.0.1
3
+ contourpy==1.0.7
4
+ cycler==0.11.0
5
+ docopt==0.6.2
6
+ filelock==3.9.0
7
+ fonttools==4.38.0
8
+ huggingface-hub==0.12.1
9
+ idna==3.4
10
+ joblib==1.2.0
11
+ kiwisolver==1.4.4
12
+ matplotlib==3.6.3
13
+ numpy==1.24.2
14
+ packaging==23.0
15
+ pandas==1.5.3
16
+ Pillow==9.4.0
17
+ pipreqs==0.4.11
18
+ pyparsing==3.0.9
19
+ python-dateutil==2.8.2
20
+ pytz==2022.7.1
21
+ PyYAML==6.0
22
+ requests==2.28.2
23
+ scikit-learn==1.2.1
24
+ scipy==1.10.0
25
+ seaborn==0.12.2
26
+ six==1.16.0
27
+ sklearn==0.0.post1
28
+ threadpoolctl==3.1.0
29
+ tqdm==4.64.1
30
+ typing_extensions==4.5.0
31
+ urllib3==1.26.14
32
+ yarg==0.1.9
saved_final_nb_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:322440f78fbc11977feac3624afbe0f767f63690bfd86740e70465eb397b53fd
3
+ size 90359
saved_final_rf_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ff7ce105305bd240bf93f7db7916dbd08bbc7dd9f6fc0564b3eeb1fba072ea3
3
+ size 7002340
saved_final_svm_model.pkl ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0ab332c2a0bb83fa1261644e60af7075168096183810cbab3d34e070973964d5
3
+ size 454711