{"id":17494612,"url":"https://github.com/bsenst/midterm-resp","last_synced_at":"2026-05-15T20:02:51.228Z","repository":{"id":82867010,"uuid":"557852424","full_name":"bsenst/midterm-resp","owner":"bsenst","description":"Experimental logistic regression model to predict respiratory disease from age, gender, symptom.","archived":false,"fork":false,"pushed_at":"2022-11-06T10:47:07.000Z","size":32,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-09T05:37:28.591Z","etag":null,"topics":["data-science","flask","healthcare","machine-learning","python3","respiratory-illnesses","symptom-checker"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bsenst.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2022-10-26T12:33:01.000Z","updated_at":"2022-11-23T12:19:55.000Z","dependencies_parsed_at":null,"dependency_job_id":"c7e73072-9116-4dc0-9b62-b54c6db64f2a","html_url":"https://github.com/bsenst/midterm-resp","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/bsenst/midterm-resp","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsenst%2Fmidterm-resp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsenst%2Fmidterm-resp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsenst%2Fmidterm-resp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsenst%2Fmidterm-resp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bsenst","download_url":"https://codeload.github.com/bsenst/midterm-resp/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bsenst%2Fmidterm-resp/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":33077936,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-15T11:35:32.926Z","status":"ssl_error","status_checked_at":"2026-05-15T11:35:31.362Z","response_time":103,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.5:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["data-science","flask","healthcare","machine-learning","python3","respiratory-illnesses","symptom-checker"],"created_at":"2024-10-19T13:28:41.197Z","updated_at":"2026-05-15T20:02:51.186Z","avatar_url":"https://github.com/bsenst.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Predicting Respiratory Disease from Age, Gender, Symptom\n\nCreating and deploying a model as described in https://github.com/alexeygrigorev/mlbookcamp-code/\n\n*Disclaimer: The only purpose of this code repository is creating and deploying an example statistical model. No medical advice. The underlying data my be wrong and any conclusion made false.*\n\nDataset: https://www.kaggle.com/datasets/abbotpatcher/respiratory-symptoms-and-treatment\n\n* 1st Notebook for EDA and initial Model: https://www.kaggle.com/code/bnzn261029/midterm-resp\n* 2nd Notebook with cleaned data (i.e. symptom list) and rebuild, second Model: https://www.kaggle.com/code/bnzn261029/fork-of-midterm-resp-symptoms-cleaned\n* 3rd Notebook with Decision Tree: https://www.kaggle.com/code/bnzn261029/midterm-resp-decision-tree\n\n### Problem Description\n\nIn medicine finding the right diagnosis is key for successful treatment and thus restituation of health. Diagnosing a disease involves several steps. It includes history taking, physical examination and diagnostic procedures followed by a preliminary list of possible diagnoses. Then estimation of the most likely diagnosis can be made through different statistic techniques and experienced clinicians develop an instinct to come to a conclusion fast. But improving the diagnostic process and reducing uncertainty is an ongoing challenge and offers opportunities for data science solutions.\n\nAhsan MM, Luna SA, Siddique Z. Machine-Learning-Based Disease Diagnosis: A Comprehensive Review. Healthcare (Basel). 2022 Mar 15;10(3):541. doi: 10.3390/healthcare10030541. PMID: 35327018; PMCID: PMC8950225.\n\nRaita Y, Camargo CA Jr, Liang L, Hasegawa K. Big Data, Data Science, and Causal Inference: A Primer for Clinicians. Front Med (Lausanne). 2021 Jul 6;8:678047. doi: 10.3389/fmed.2021.678047. PMID: 34295910; PMCID: PMC8290071.\n\n### Example\n\nInput (as used in test_service.py)\n\n\tpatient = {\n\t\t'Age': 60,\n\t\t'Sex=female': 0, \n\t\t'Sex=male': 1, \n\t\t'Sex=not to say': 0,\n\t\t'Symptoms_encoded': 48,\n\t}\n\nOr send curl request to Flask API https://bsenst.pythonanywhere.com/predict (availability not guaranteed)\n\n\tcurl --location --request POST 'https://bsenst.pythonanywhere.com/predict' \\\n\t--header 'Content-Type: application/json' \\\n\t--data-raw '{\"Age\": 60, \"Sex=female\": 0, \"Sex=male\": 1, \"Sex=not to say\": 0, \"Symptoms_encoded\": 48}'\n\nOutput (response from the model served as flask app):\n\n\t{\n\t  \"disclaimer\": \"This script is for educational purpose only.\",\n\t  \"disease\": \"Pneumonia\",\n\t  \"disease_probability\": 0.19968054490140236,\n\t  \"patient:\": {\n\t\t\"Age\": 60,\n\t\t\"Sex=female\": 0,\n\t\t\"Sex=male\": 1,\n\t\t\"Sex=not to say\": 0,\n\t\t\"Symptoms_encoded\": 48\n\t  }\n\t}\n\t\nThis version of the model suffers from low accuracy. For a male 60 years old patient with a cold it predicts pneumonia with a probability of 20 %. If the age is changed to 10 years old it suggests bronchitis with a probability of 22 %.\n\nOutput:\n\n\t{\n\t  \"disclaimer\": \"This script is for educational purpose only.\",\n\t  \"disease\": \"bronchitis\",\n\t  \"disease_probability\": 0.2179886636147549,\n\t  \"patient:\": {\n\t\t\"Age\": 10,\n\t\t\"Sex=female\": 0,\n\t\t\"Sex=male\": 1,\n\t\t\"Sex=not to say\": 0,\n\t\t\"Symptoms_encoded\": 48\n\t  }\n\t}\n\n### Run the Service using Python\n\nCreate virtual environment (as described in [https://docs.python.org/3/tutorial/venv.html](https://docs.python.org/3/tutorial/venv.html))\n\n\tpython3 -m venv virtualenv\n\t\nThen activate the virtual environment for Windows\n\n\tvirtualenv\\Scripts\\activate.bat\n\nOr on Unix/MacOS\n\t\n\tsource virtualenv/bin/activate\n\t\nInstall requirements\n\n\tpip install -r requirements.txt\n\nRun the flask app\n\n\tpython flask_app.py\n\nOpen another command window and run the example post request\n\n\tpython test_service.py\n\nMake sure the test script sends the request to the url the flask app is being served (i.e. https://172.17.0.2:9696).\n\t\n### Run the Service using Docker\n\nDownload the docker image (206.6 MB)\n\n\tdocker pull fritz.jfrog.io/default-docker-local/midterm-resp-docker:latest\n\nCompare the checksum sha256 78583fdc866a728a2d3588d3d7c45b44b7a9f9a9c2175e81688d9ec5ab6d5a42\n\nBuild and run the docker image\n\t\n\tdocker build --tag midterm-resp-docker\n\n\tdocker run midterm-resp-docker\n\nYou should see that the flask app is being served. Open another terminal and run the test script.\n\n\tpython test_service.py\n\nMake sure the test script sends the request to the url the flask app is being served (i.e. https://172.17.0.2:9696).\n\n### \n\n\n\n### Labels\n\nLabelEncoder() Disease:\n\n|Label |Disease|\n|--- |---|\n|0 |Acute Respiratory Distress Syndrome|\n|1 |Asbestosis|\n|2 |Aspergillosis|\n|3 |Asthma|\n|4 |Bronchiectasis|\n|5 |Chronic Bronchitis|\n|6 |Influenza|\n|7 |Mesothelioma|\n|8 |Pneumonia|\n|9 |Pneumothorax|\n|10 |Pulmonary hypertension|\n|11 |Respiratory syncytial virus|\n|12 |Tuberculosis|\n|13 |bronchiolitis|\n|14 |bronchitis|\n|15 |chronic obstructive pulmonary disease|\n|16 |sleep apnea|\n\nLabelEncoder() Symptoms:\n\n|Label |Symptom|\n|--- |---|\n|0  |coughing|\n|1  |coughing|\n|2  |fatigue|\n|3  |low energy|\n|4  |shortness of breath|\n|5  |wheezing|\n|6 |A cough that lasts more than three weeks|\n|7 |A dry, crackling sound in the lungs while breathing in|\n|8 |Bluish skin|\n|9 |Chest congestion|\n|10 |Chest pain|\n|11 |Chills|\n|12 |Coughing up blood|\n|13 |Coughing up yellow or green mucus daily|\n|14 |Daytime sleepiness|\n|15 |Difficulties with memory and concentration|\n|16 |Dry mouth|\n|17 |Fatigue|\n|18 |Fatigue, feeling run-down or tired|\n|19 |Feeling run-down or tired|\n|20 |Fever|\n|21 |Frequently waking|\n|22 |Headache|\n|23 |Loss of appetite|\n|24 |Loss of appetite and unintentional weight loss|\n|25 |Low-grade fever|\n|26 |Morning headaches|\n|27 |Nasal congestion|\n|28 |Nausea|\n|29 |Night sweats|\n|30 |Pauses in breathing|\n|31 |Persistent dry coug|\n|32 |Persistent dry cough|\n|33 |Rapid breathing|\n|34 |Rapid heartbeat|\n|35 |Runny nose|\n|36 |Shortness of breath|\n|37 |Shortness of breath that gets worse during flare-ups|\n|38 |Snoring|\n|39 |Sore throat|\n|40 |Unusual moodiness|\n|41 |Weight loss from loss of appetite|\n|42 |Wheezing|\n|43 |Wider and rounder than normal fingertips and toes|\n|44 |allergy|\n|45 |breath|\n|46 |chest pain|\n|47 |chronic cough|\n|48 |cold|\n|49 |cough|\n|50 |cough with blood|\n|51 |coughing|\n|52 |diarrhea|\n|53 |distressing|\n|54 |dizziness|\n|55 |dry cough|\n|56 |edema|\n|57 |fainting|\n|58 |faster heart beating|\n|59 |fatigue|\n|60 |fever|\n|61 |greenish cough|\n|62 |heart palpitations|\n|63 |high fever|\n|64 |irritability|\n|65 |joint pain|\n|66 |loss of appetite|\n|67 |low energy|\n|68 |lower back pain|\n|69 |mucus|\n|70 |muscle aches|\n|71 |nausea|\n|72 |pain|\n|73 |runny nose|\n|74 |shaking|\n|75 |shallow breathing|\n|76 |sharp chest pain|\n|77 |short of breath|\n|78 |short, shallow and rapid breathing|\n|79 |shortness of breath|\n|80 |stuffy nose|\n|81 |sweating|\n|82 |tight feeling in the chest|\n|83 |vomiting|\n|84 |weight loss|\n|85 |wheezing|\n|86 |wheezing cough|\n|87 |whistling sound while breathing|\n|88 |whistling sound while you breathe|\n|89 |yellow cough|","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsenst%2Fmidterm-resp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbsenst%2Fmidterm-resp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbsenst%2Fmidterm-resp/lists"}