├── README.md ├── NB_model.pkl ├── SVM_model.pkl ├── rfc_model.pkl ├── logreg_model.pkl ├── templates └── index.html ├── sample.html └── app.py /README.md: -------------------------------------------------------------------------------- 1 | # Disease_predictor -------------------------------------------------------------------------------- /NB_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HarishVaradharajan/Disease_predictor/HEAD/NB_model.pkl -------------------------------------------------------------------------------- /SVM_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HarishVaradharajan/Disease_predictor/HEAD/SVM_model.pkl -------------------------------------------------------------------------------- /rfc_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HarishVaradharajan/Disease_predictor/HEAD/rfc_model.pkl -------------------------------------------------------------------------------- /logreg_model.pkl: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/HarishVaradharajan/Disease_predictor/HEAD/logreg_model.pkl -------------------------------------------------------------------------------- /templates/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Disease Predictor 5 | 6 | 7 | 20 | 21 | 22 | 23 |
24 |

Disease Predictor

25 |
26 | 27 |
28 | 29 | 30 | 31 |
32 |
33 | 34 | 35 | 65 | 66 | 67 | -------------------------------------------------------------------------------- /sample.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Google Search 5 | 6 | 81 | 82 | 83 | 84 | 87 | 88 | 89 |
90 |
91 |

KNOW YOUR DISEASE

92 |
93 | 94 |
95 | 96 |
97 |
98 | 99 |
100 |
101 |
102 | 103 |
104 | 105 |
106 | 107 | 108 | 109 | 139 | 140 | 141 | -------------------------------------------------------------------------------- /app.py: -------------------------------------------------------------------------------- 1 | from flask import Flask, render_template, request, jsonify 2 | import pandas as pd 3 | from sklearn.model_selection import train_test_split 4 | from sklearn.preprocessing import LabelEncoder 5 | import pickle 6 | 7 | app = Flask(__name__) 8 | 9 | # Load data and models 10 | df = pd.read_csv("dataset1.csv") 11 | le = LabelEncoder() 12 | df["prognosis"] = le.fit_transform(df["prognosis"]) 13 | 14 | X = df.drop(["prognosis"], axis=1) 15 | y = df["prognosis"] 16 | X_train, X_test, y_train, y_test = train_test_split(X, y, test_size=0.2) 17 | 18 | models = { 19 | "SVM": pickle.load(open("SVM_model.pkl", 'rb')), 20 | "Random Forest": pickle.load(open("rfc_model.pkl", 'rb')), 21 | "Naive Bayes": pickle.load(open("NB_model.pkl", 'rb')), 22 | "Logistic Regression": pickle.load(open("logreg_model.pkl", 'rb')), 23 | } 24 | 25 | symptoms = ['itching', 'skin_rash', 'nodal_skin_eruptions', 'continuous_sneezing', 'shivering', 'chills', 'joint_pain', 26 | 'stomach_pain', 'acidity', 'ulcers_on_tongue', 'muscle_wasting', 'vomiting', 'burning_micturition', 27 | 'spotting_ urination', 'fatigue', 'weight_gain', 'anxiety', 'cold_hands_and_feets', 'mood_swings', 28 | 'weight_loss', 'restlessness', 'lethargy', 'patches_in_throat', 'irregular_sugar_level', 'cough', 'high_fever', 29 | 'sunken_eyes', 'breathlessness', 'sweating', 'dehydration', 'indigestion', 'headache', 'yellowish_skin', 30 | 'dark_urine', 'nausea', 'loss_of_appetite', 'pain_behind_the_eyes', 'back_pain', 'constipation', 31 | 'abdominal_pain', 'diarrhoea', 'mild_fever', 'yellow_urine', 'yellowing_of_eyes', 'acute_liver_failure', 32 | 'fluid_overload', 'swelling_of_stomach', 'swelled_lymph_nodes', 'malaise', 'blurred_and_distorted_vision', 33 | 'phlegm', 'throat_irritation', 'redness_of_eyes', 'sinus_pressure', 'runny_nose', 'congestion', 'chest_pain', 34 | 'weakness_in_limbs', 'fast_heart_rate', 'pain_during_bowel_movements', 'pain_in_anal_region', 'bloody_stool', 35 | 'irritation_in_anus', 'neck_pain', 'dizziness', 'cramps', 'bruising', 'obesity', 'swollen_legs', 36 | 'swollen_blood_vessels', 'puffy_face_and_eyes', 'enlarged_thyroid', 'brittle_nails', 'swollen_extremeties', 37 | 'excessive_hunger', 'extra_marital_contacts', 'drying_and_tingling_lips', 'slurred_speech', 'knee_pain', 38 | 'hip_joint_pain', 'muscle_weakness', 'stiff_neck', 'swelling_joints', 'movement_stiffness', 39 | 'spinning_movements', 'loss_of_balance', 'unsteadiness', 'weakness_of_one_body_side', 'loss_of_smell', 40 | 'bladder_discomfort', 'foul_smell_of urine', 'continuous_feel_of_urine', 'passage_of_gases', 41 | 'internal_itching', 'toxic_look_(typhos)', 'depression', 'irritability', 'muscle_pain', 'altered_sensorium', 42 | 'red_spots_over_body', 'belly_pain', 'abnormal_menstruation', 'dischromic _patches', 'watering_from_eyes', 43 | 'increased_appetite', 'polyuria', 'family_history', 'mucoid_sputum', 'rusty_sputum', 'lack_of_concentration', 44 | 'visual_disturbances', 'receiving_blood_transfusion', 'receiving_unsterile_injections', 'coma', 45 | 'stomach_bleeding', 'distention_of_abdomen', 'history_of_alcohol_consumption', 'fluid_overload', 46 | 'blood_in_sputum', 'prominent_veins_on_calf', 'palpitations', 'painful_walking', 'pus_filled_pimples', 47 | 'blackheads', 'scurring', 'skin_peeling', 'silver_like_dusting', 'small_dents_in_nails', 48 | 'inflammatory_nails', 'blister', 'red_sore_around_nose', 'yellow_crust_ooze'] 49 | 50 | disease = ['Fungal infection', 'Allergy', 'GERD', 'Chronic cholestasis', 'Drug Reaction', 51 | 'Peptic ulcer diseae', 'AIDS', 'Diabetes', 'Gastroenteritis', 'Bronchial Asthma', 'Hypertension', 52 | ' Migraine', 'Cervical spondylosis', 'Paralysis (brain hemorrhage)', 'Jaundice', 'Malaria', 'Chicken pox', 53 | 'Dengue', 'Typhoid', 'hepatitis A', 'Hepatitis B', 'Hepatitis C', 'Hepatitis D', 'Hepatitis E', 54 | 'Alcoholic hepatitis', 'Tuberculosis', 'Common Cold', 'Pneumonia', 'Dimorphic hemmorhoids(piles)', 55 | 'Heartattack', 'Varicoseveins', 'Hypothyroidism', 'Hyperthyroidism', 'Hypoglycemia', 'Osteoarthristis', 56 | 'Arthritis', '(vertigo) Paroymsal Positional Vertigo', 'Acne', 'Urinary tract infection', 'Psoriasis', 57 | 'Impetigo'] 58 | symptoms.sort() 59 | @app.route('/') 60 | def index(): 61 | return render_template('index.html', symptoms=symptoms) 62 | 63 | @app.route('/predict', methods=['POST']) 64 | def predict(): 65 | selected_symptoms = request.form.getlist('symptoms') 66 | predictions = predict_disease(*selected_symptoms) 67 | results = "

Predictions:

" 71 | return results 72 | 73 | def predict_disease(*selected_symptoms): 74 | predictions = [] 75 | for model_name, model in models.items(): 76 | input_test = [1 if s in selected_symptoms else 0 for s in symptoms] 77 | prediction = model.predict([input_test]) 78 | predictions.append(f"{model_name}: {disease[prediction[0]]}") 79 | return predictions 80 | 81 | if __name__ == '__main__': 82 | app.run(debug=True) 83 | --------------------------------------------------------------------------------