Achoo uses a Raspberry Pi to predict if my son will need his inhaler on any given day using weather, pollen, and air quality data. If the prediction for a given day is above a specified threshold, the Pi will email his school nurse, and myself, notifying her that he may need preemptive treatment. TUTORIAL COMING SOON
Prompted by this reddit post. Lots of great ideas in there.
UPDATE
I will be updating this readme fairly often for the next week or two to make sure the code and instructions are as readable as possible.
First, you'll want to declare a few environment variables:
FROM_EMAIL
- the sender's email address.
TO_EMAIL
- the email addresses to send the alerts to.
GMAIL_PASSWORD
- to send emails (if you don't already have one) you'll need to register an app with gmail.
USERNAME
- the PostgreSQL username (or other database).
PASSWORD
- PostgreSQL password.
DARK_SKY_API_KEY
- for the weather data, I'm using Dark Sky. You get 1,000 free hits a day. Their pricing is really affordabe.
DARK_SKY_LOCATION
- The latitude, longitude for the location you'll be tracking.
POLLEN_ZIPCODE
- The zipcode you'll be tracking.
For now, the work flow is reflected in the bash script that runs daily:
#!/bin/bash
Rscript train_model.r &&
python get_allergy_data.py && python get_weather_data.py && python get_air_data.py &&
Rscript run_model.r &&
python get_resutls_send_email.py
- Train the model (this assumes we have data, so I'll upload some test data that I've been using)
- Get all weather, allergy, and air quality data
- Run the model (this will write the results to the database after every run)
- Retrieve the results (this is the step that sends the email if the prediction is greater than X).
This bash script currently runs as a cron job.
To record the inhaler/breathing treatment data, you'll run treatment_tracker.py
from your Raspberry Pi like this:
$ python treatment_tracker.py &
I have two buttons on my Pi: one for his breathing treatment, the other for his inhaler (pics and a blog post coming soon).
Outstanding questions
- Is there a better way than using a cron job?
- The Raspberry Pi isn't ideal. Maybe we should be using Nomie 2 to record events? (HT to sujins for this suggestion). I'd like to make it easy for the user to add their own method and their own host for storing data.
- I have a feeling many users will want to easily add their own models (Nueral Networks, GBMs, GLMs, etc.). What is the best way for users to add their own models?
- Should we support two languages? Currently I'm using Python and R.
- I still have a lot of architectural concerns about this project so far, but I'm hoping things will be more smooth as a couple weeks' worth of development pass.
- LONG TERM: How to make this non-developer friendly? How can the typical person with allergies/asthma make use of this day-to-day? Can we make this a mobile app? I think this is my end goal.