{"id":19989203,"url":"https://github.com/clamytoe/covid-risk-classifier","last_synced_at":"2025-05-04T09:32:41.604Z","repository":{"id":84639541,"uuid":"561443353","full_name":"clamytoe/covid-risk-classifier","owner":"clamytoe","description":"How likely are you to die if you take the shot?","archived":false,"fork":false,"pushed_at":"2022-11-16T21:11:24.000Z","size":3570,"stargazers_count":7,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-04-08T06:30:24.880Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Jupyter Notebook","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/clamytoe.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","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-11-03T17:45:57.000Z","updated_at":"2023-02-12T22:44:52.000Z","dependencies_parsed_at":"2023-07-21T01:03:45.511Z","dependency_job_id":null,"html_url":"https://github.com/clamytoe/covid-risk-classifier","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clamytoe%2Fcovid-risk-classifier","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clamytoe%2Fcovid-risk-classifier/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clamytoe%2Fcovid-risk-classifier/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/clamytoe%2Fcovid-risk-classifier/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/clamytoe","download_url":"https://codeload.github.com/clamytoe/covid-risk-classifier/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":252316508,"owners_count":21728520,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","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":[],"created_at":"2024-11-13T04:45:49.420Z","updated_at":"2025-05-04T09:32:41.591Z","avatar_url":"https://github.com/clamytoe.png","language":"Jupyter Notebook","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Covid Risk Classifier\n\n```bash\n ▄████████  ▄█          ▄████████   ▄▄▄▄███▄▄▄▄   ▄██   ▄       ███      ▄██████▄     ▄████████ \n███    ███ ███         ███    ███ ▄██▀▀▀███▀▀▀██▄ ███   ██▄ ▀█████████▄ ███    ███   ███    ███ \n███    █▀  ███         ███    ███ ███   ███   ███ ███▄▄▄███    ▀███▀▀██ ███    ███   ███    █▀  \n███        ███         ███    ███ ███   ███   ███ ▀▀▀▀▀▀███     ███   ▀ ███    ███  ▄███▄▄▄     \n███        ███       ▀███████████ ███   ███   ███ ▄██   ███     ███     ███    ███ ▀▀███▀▀▀     \n███    █▄  ███         ███    ███ ███   ███   ███ ███   ███     ███     ███    ███   ███    █▄  \n███    ███ ███▌    ▄   ███    ███ ███   ███   ███ ███   ███     ███     ███    ███   ███    ███ \n████████▀  █████▄▄██   ███    █▀   ▀█   ███   █▀   ▀█████▀     ▄████▀    ▀██████▀    ██████████ \n           ▀                                                                                    \n```\n\n## What does this do?\n\nThis classifier will predict the likelyhood of someone dying from taking the covid vaccination.\nThe dataset was collected from the [Vaccine Adverse Event Reporting System (VAERS)](https://vaers.hhs.gov/), which is an arm of the [U.S. Department of Health \u0026 Human Services (HHS)](https://www.hhs.gov/).\n\nIf you are interested in the actual raw data, the datasets can be downloaded from the VAERS Data Sets: [https://vaers.hhs.gov/data/datasets.html](https://vaers.hhs.gov/data/datasets.html).\n\nThese are the two datasets that were used:\n\n* 2022VAERSDATA.csv\n* 2022VAERSVAX.csv\n\n## Running the model\n\nThe fastest way for you to run this model is to simply get the docker image [clamytoe/covid_risk_classifier](https://hub.docker.com/r/clamytoe/covid_risk_classifier) and run it locally.\n\n### Download the image\n\n```docker\ndocker pull clamytoe/covid_risk_classifier\n```\n\n### Start the service\n\n```docker\ndocker run -it --rm -p 3000:3000 clamytoe/covid_risk_classifier serve --production\n```\n\n### Using the service\n\nYou can use the API by simply opening a browser to \u003chttp://localhost:3000\u003e\n\n![main-interface](images/main-interface.png)\n\nIf you scroll down a bit until you get to the **Service APIs** section and click on the **POST** drop down.\n\n![post](images/post.png)\n\nOnce you've clicked on it to expand it, you will see a **Try it out** button.\n\n![try-it-out](images/try-it-out.png)\n\nClicking on it will expose a text area with a schema of a valid input.\n\n![schema](images/schema.png)\n\nEnter your own values to try it out.\nDue take note that at the top of the page, a description of each value is provided along with acceptable values.\n\nHere is a sample for you to try:\n\n```json\n{\n  \"state\": \"tx\",\n  \"age_yrs\": 52,\n  \"sex\": \"f\",\n  \"disable\": 0,\n  \"other_meds\": 1,\n  \"cur_ill\": 0,\n  \"history\": 0,\n  \"prior_vax\": 0,\n  \"ofc_visit\": 0,\n  \"allergies\": 0,\n  \"vax_name\": \"moderna\",\n  \"vax_dose_series\": 1\n}\n```\n\n![sample](images/sample.png)\n\nOnce you've entered your values, just click on the **Execute** button and scroll down a bit until you get to the *Server response* section.\n\n![results](images/results.png)\n\nIn this case, we see that the user should be cautious if planning to take it.\n\n## Sending multiple requests\n\nIf entering each patient's data takes too long, you can do something like what I'm doing with my `predict.py` script.\n\n*predict.py:*\n\n```python\nimport json\n\nimport requests\n\nfrom service import CovidRisk\n\npatients: list[CovidRisk] = [\n    {\n        \"state\": \"mi\",\n        \"age_yrs\": 85,\n        \"sex\": \"f\",\n        \"disable\": 0,\n        \"other_meds\": 0,\n        \"cur_ill\": 0,\n        \"history\": 0,\n        \"prior_vax\": 0,\n        \"ofc_visit\": 0,\n        \"allergies\": 0,\n        \"vax_name\": \"pfizer\\\\biontech\",\n        \"vax_dose_series\": 2,\n    },\n    ...\n    {\n        \"state\": \"tx\",\n        \"age_yrs\": 52,\n        \"sex\": \"f\",\n        \"disable\": 0,\n        \"other_meds\": 1,\n        \"cur_ill\": 0,\n        \"history\": 0,\n        \"prior_vax\": 0,\n        \"ofc_visit\": 0,\n        \"allergies\": 0,\n        \"vax_name\": \"moderna\",\n        \"vax_dose_series\": 1,\n    },\n]\n\n\ndef test_service(data: List[CovidRisk]):\n    for patient in data:\n        patient = json.dumps(patient)\n        response = requests.post(\n            \"http://localhost:3000/classify\",\n            headers={\"content-type\": \"application/json\"},\n            data=patient,\n        ).json()\n        print(response[\"status\"], response[\"proba\"])\n\n\nif __name__ == \"__main__\":\n    test_service(patients)\n```\n\n## Logging\n\nI've enabled logging for the service.\nIn order to be able to keep the logs you will have to create a local mount point or a docker volume.\nThat's beyong the scope of this project, so I will leave that up to you to implement on your own.\n\n### Log file location\n\n* If you run the service locally, it is created in your project's root directory as `covid_risk_classifier.log`.\n* If you run it from a docker image, it is created in `/home/bentoml/bento/src` with the same name.\n\n*sample log entries:*\n\n```log\ncat covid_risk_classifier.log\n...\n2022-11-04T23:01:51.342665+0000 INFO Processing: state='tx' age_yrs=53 sex='f' disable=False other_meds=False cur_ill=False history=False prior_vax=False ofc_visit=False allergies=False vax_name='pfizer\\\\biontech' vax_dose_series=1\n2022-11-04T23:01:51.347936+0000 INFO Probability: 0.19510182738304138\n2022-11-04T23:01:51.348160+0000 INFO Prediction: {'status': 'SAFE', 'proba': 0.19510183}\n2022-11-04T23:01:51.351920+0000 INFO Processing: state='ca' age_yrs=3 sex='m' disable=False other_meds=False cur_ill=False history=False prior_vax=False ofc_visit=False allergies=False vax_name='moderna' vax_dose_series=1\n2022-11-04T23:01:51.357594+0000 INFO Probability: 0.003593571949750185\n2022-11-04T23:01:51.357773+0000 INFO Prediction: {'status': 'SAFE', 'proba': 0.003593572}\n2022-11-04T23:01:51.361099+0000 INFO Processing: state='tx' age_yrs=52 sex='f' disable=False other_meds=True cur_ill=False history=False prior_vax=False ofc_visit=False allergies=False vax_name='moderna' vax_dose_series=1\n2022-11-04T23:01:51.366562+0000 INFO Probability: 0.13526801764965057\n2022-11-04T23:01:51.366764+0000 INFO Prediction: {'status': 'SAFE', 'proba': 0.13526802}\n```\n\n## Short demo of it running on AWS\n\n[![demo](images/demo.png)](https://youtu.be/DiqvK98TG68)\n\n## Further reading\n\nIf you want to dig in more and take a look at what it takes to create your own classifier, then a look at the [HOW-TO.md](HOW-TO.md) file.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclamytoe%2Fcovid-risk-classifier","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fclamytoe%2Fcovid-risk-classifier","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fclamytoe%2Fcovid-risk-classifier/lists"}