Fitbit Data Analysis

I bought a fitbit in late January and am starting to see what I can do with it. I don’t find the information fitbit gives me on their website particularly interesting and I find it hard to navigate to anything that shows me more than one day’s worth of data. Even less so do I like what the app shows me. The app shows me what I’ve done today, to which I can only think: Duh. I was there. I remember. You can pay for a premium account and get more, but I bought the fitbit to play with the data myself so that seems worthless.

I’m most interested in the sleep data, particularly when it says I’m ‘restless’ at night. I’m curious if that means anything and could somehow be correlated with depth of sleep or quality of sleep. It might mean nothing. Having worked with raw wearable tech data before, I know the challenge of getting algorithms that are accurate for every user and it may be that restless doesn’t measure anything significant for me. Still, try, try again.

I struggled for a while to figure out how to download my data. Finally I found this post which outlines how Andrew Wilkinson does it in python and includes a link to his code. His code works pretty flawlessly except if you have a couple days of no steps (which I do, because sometimes my fitbit runs out of battery before I can recharge it.) His code takes that as a sign that there is no previous data. I did a crappy fix of this by having the code think today is one day earlier than the no data day, mostly because I plan to dump my data frequently enough in the future that this shouldn’t be a problem.

The first thing I wanted to do was pretty straightforward and hopefully you can see it in the graph below:feb-may_sleepdataBasically I aggregated all my sleep data from the past 4 months and looked how often I was asleep at any given time, as well as how often I was restless + asleep. It turns out that I have a very consistent sleep schedule! I rock. It’s interesting to look at the shape of the curve. It looks a little like I’m more likely to go to bed late than wake up late, but there’s also almost a step function between 6:30am and 8am.

The really large discontinuity at 8am probably has to do with my estimation of when I wake up — that is, the fitbit requires you to estimate when you were asleep and then it tells you, within that time, when it thought you were restless and when it thought you were awake. If I estimate my waking time too early than my estimated time is the wake up time, as opposed to fitbit’s algorithms estimating when I actually moved around and got out of bed.

Looking at the times when I am most restless, the first “peak”, if you can call it that, seems fairly straightforward. It takes some time to get to sleep, during that time I probably roll around a decent amount. The second one, in the morning, perhaps alludes to the same thing in the morning — i.e. a period of restlessness before I wake up — but that would only be true if the days I’m restless at that time I also wake up at 6:30am. Otherwise it would indicate that 6am I wake up briefly and then go back to sleep until 8am, which could also be true. In order to figure that out, I need to look deeper into the data.

I plan to put up my code for generating this graph on gitHub and write another post briefly walking through it.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s