Qualified Self: HealthKPI

So, this is a bit of passion project, I’ve been working on in some capacity for the past 12 or so years. It is at the intersection of computer science, statistics and psychology. It attempts the same as I did in my PhD thesis and with the MBT Workbench: to make advanced analysis tools available to people who don’t know (and aren’t interested in) the underlying theory.

HealthKPI attempts to combine all of the health data recorded by devices around to provide actionable suggestions for reaching your goals. Actionable is a key word here: the goal is not to provide dumb recurring reminders telling you to go running while it is raining or dumb achievements that take the joy out of achieving your goals for the goals themselves. HealthKPI is not just quantified self, providing you with numbers about how far and how long you biked, but qualified self, providing you with meaningful insights about when to go biking.

The first foundation for HealthKPI was laid around 12 years during a tumultuous time in my personal life, which included leaving university after 8 years for my first grown-up job, also at the same university. I was trying to change a largely sedentary lifestyle, so I made a goal tracker. You’d set a goal to do an action at least or at most a certain number of times. The app would provide charts and statistics about how well you achieved your goal. It worked really well for me because unless achievement-based trackers it would not punish you for missing a day.

Around half a decade ago, I had pretty bad depression for a while. As part of that, I saw a psychologists and went thru training for cognitive behavioural therapy, which is basically the catch-all non-medicinal way to treat “head no workie,” and involves recognising when something leads to undesired automatic thoughts by basically consciously recognising when it happens and consciously challenging the automatic thoughts. That’s when I came up with the idea for HealthKPI: what if that but for general goals?

The idea was what if it were possible to gather data from “everywhere” and correlate it to recognize what leads to bad mood? or when I am bound to cheat on my diet? or when it is a good time to go exercising? Data could come from a ton of sources; I have pretty much the entire set of gear from Withings, including smart scale and sleep tracker, a fitness tracker, a phone with GPS and heaps of other things. With the data from my goal tracker, surely I could hack something together…

The first things I was looking at was a few missing data sources, most importantly a mood tracker. I found one, MoodPanda, which amazingly seems to still exist. It was close, but not really what I wanted – it is less focused on tracking mood and more on serving as a hugbox for teenagers with too many feelings. I therefore ended up writing my own. It needed to be simple to use but support logging detailed data. I set it up to support logging either on a scale from sad to happy or by basically Plutchik’s wheel of emotions categorising one’s mood on 4 dimensions with 8 extremes. From MoodPanda, I adopted (stole) the idea of annotating each registration with a custom note.

With a mood tracker, a goal tracker, and an idea, I proceeded to immediately get distracted. Also, by this time I was spending most of my free time studying psychology. Problem was that at the core of the idea, I needed to gather data from at least half a dozen data sources to correlate it. Also, while my goal tracker was generally working wonders, my mood tracker was not. Being a web-app, I’d have to go to it to make a registration, meaning that even when it was new, I’d make at most 1-2 registrations/day, and mostly when at the extremes. In psychological research, mood is measured by randomly prompting people to register their mood. Doing this from a web-site is super-annoying, so I didn’t bother.

The past years, the landscape has changed quite a bit; now, “everybody” wants to be the hub for everything. Relevant here, everybody is trying to scoop up all of the health data. Apple has Apple Health, Nokia bought and sold Withings, Microsoft has… something. As does Google. That means that instead of integrating with half a dozen to a dozen different web-services, it is possible to just integrate with one hub. Moving everything to mobile also solves the PII issues of collecting all of this highly sensitive data in some cloud. Finally, being on mobile means I can easily send notifications. The only problem is that iOS was mostly coded in ObjectiveC at the time and also I was still pretty pre-occupied with studies and model-based testing.

About a month ago, the old idea popped back into my head, and I picked up a book about Swift, proceeded to get bored after a chapter and a half, instead went thru 2 online tutorials on Swift and SwiftUI and started to rewrite my goal and mood trackers as an iOS app.

Now, I’m nearing finalisation of version 1. The goal for version 1 is to match the functionality of the existing mood and goal trackers on the iPhone, and add a few niceties. Most importantly, I want to also register the GPS coordinates of each entry, and I want to provide notifications for mood sampling, mimicking how such data is collected during clinical trials.

For now, this is the new goal tracker (goal overview, add new goal, goal details):

This is the new mood tracker (register mood, mood statistics):

The only really new feature is that the mood overview now shows a map with mood grouped by location instead of time (work in progress); the goal overview will have clusters of where goals were completed. All of the data is a mixture of test data and real data, by the way, so don’t make any wild conclusions based on the screen shots, thanks 🙂

The goal of the app is not to make the users the product, but to empower users. That means privacy is very important. The first version will keep all data on the device (with an option to export it all as a JSON file). Users can selectively enable/disable all sensitive/annoying functionality and nothing will break except for the functionality that uses it (so, if you don’t allow the application access to your location you will of course not get any location-based information, but all other functionality will work just the same). I also integrate with modern APIs for proper security.

The only network functionality right now, is the live view of my issue board including road map. For now, the plan is:

Version 1: basic functionality from current web apps plus notifications for mood sampling (and maybe goal reminders), registration of location with normal registrations and viewing them on a map. At some point during version 1 or 2, I also want to include today widgets, allowing easy access to a scaled down version of the goal overview and mood registration page, and to make a simple Apple Watch app with similar functionality. While this all sounds very boring compared to especially version 3 below, this is the functionality I have been using for 12 years and which has successfully gotten me to adopt or drop habits.

Version 2: goals tracking Apple Health metrics. I already have preliminary scraping of data working, but want to be able to define goals both directly from the metrics but also for more abstract data. Direct data is already interesting, because a bike exercise is not just a bike exercise; it is possible to measure frequency, distance, duration, and calories burned. And there’s both indoor and outdoor biking. Of course, one might also envision more general “exercise” goals with similar categories but scraping across workout types. Of course, Health also has measurements like weight, blood pressure, step counts, sleep duration/quality, tooth brushing (yes, really) and heaps of dietary information. This version allows defining goals that automatically track this data and provides statistics for improvement like is currently gathered manually using the mood and goal trackers.

Version 3 is the big one: correlation of health data with defined goals. Aside from the primary data, data inherently has time information, which can be broken into time of day, day of week, day of month, month of year. There’s also often location data, weather data and of course all of the other series. I could just be lazy and buzz-wordy and throw everything at a deep neural network and probably get something that can predict from a situation whether it is going to work for or against a goal, but the aim it not just to provide blind predictions, but to provide actionable suggestions. For example, if it sees I am out in town on a Friday night it can probably predict this will have bad influence of diet and exercise goals and can give a well-timed warning and jolt of bad conscience, or if it predicts bad mood, perhaps due to it being rainy and November, it should not suggest moving to May but instead suggest going to the movies. The goal is to provide limited but relevant encouragement and warnings based on available data. I am looking into various statistical methods for achieving this.

For now, I am focusing on getting version 1 ready for beta test, likely the 5 in-progress milestones from the roadmap except Health MVP and the notifications milestone from the backlog.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.