Finding patterns within Fitbit's sleep data
On May 28, 2019, I left my old life behind, boarded a train, and started my backpacking adventure.
Being the data person I am, I thought that besides documenting my travels through beautiful and colorful pictures, I could also record it and relive my experiences through data.
In this recap, I will share and analyze the data I gathered during my last days in the mountains of Tyrol in Austria. Like the previous weeks, I'll once again present and plot the data I acquired through Fitbit, Spotify, and my sensors app. Moreover, as I said in the last recap, on this occasion, I'll complement the light intensity data with another data source, the cloudiness index, provided by OpenWeatherMap API.
Tyrolean sunset. By me.
My favorite thing about owning an activity tracker such as Fitbit, is not the device itself, but the data it provides. Having such a small and easy-to-use tool stuck in your arm, collecting data 24/7, gives us the opportunity of performing longitudinal studies with the information it gathers.
For the visualizations I'll be presenting in this section, I collected Fitbit data about my activity (active and non-active minutes), movement (number of steps, kilometers walked, and meters climbed), and sleeping patterns. To get the data, I used Fitbit's API, and the Python library "python-fitbit" to interface with it. Now, time to see the graphs.
The first plot I'll introduce shows my steps taken, and distance traveled – in log scale – from June 16, 2019, until June 27, 2019.
June 18. That's a date I'll keep referencing throughout this article. What makes this day special is that on that day I hiked all the way up to a cabin called Nördlinger Hütte, located at 2239 meters. As you might expect, I walked a lot – 28514 steps or 13.4 km. to be exact – and the plot shows this. The second peak on June 23 marks another hiking day. This time it was the Gaistal valley, which even though is not as high as the previous mountain, the walk is quite a marathon. To give you an idea, I climbed parts of the hill on a bike and made the downhill trip entirely on it. Otherwise, the number of steps would be way higher. In general, the average number of steps per day was 8275.74, with a standard deviation of 5788.86.
This recap's elevation plot shows a significant peak on June 18, the hiking day, in which I ascended 1146 meters to reach my goal. Why didn't Fitbit register the whole 2239 meters? That's because the starting point was located at 1130 meters. Other than this observation, the other signification highlight of the week was the short climb in the valley.
So far, I have talked about hiking, bikes, sweating, and such, terms that evoke feelings of exercise and activity. But what does the data say about this? The next chart is about my activity levels.
Let's start with the blue line, which describes the sedentary minutes. This time, the average was a 706.32 sedentary minutes per day, 3 less than the previous recap, which was already 14 less than the first reported score. However, before I start to celebrate and name myself the most active person on Earth, you have to consider the fact that the hiking day was an outlier, so it'll bring down the average value. In summary, over these 12 days, I collected a total of 21896 sedentary minutes, 6805 lightly active minutes (average of 219.52), 818 fairly active minutes (avg. of 26.39) and 729 very active ones (avg. of 23.52).
The last piece of information I want to present in this section is about my sleeping times. You might think that since I am living that hostel and wanderer life, I would spend the whole day sleeping. Wrong! As you'll see, my sleeping patterns are not that out of the ordinary.
This graph above shows what Fitbit has recorded as my sleeping start time and end time. The red line indicates the start time, and it clearly states that I never went to bed before midnight; the average time was 1:23 am. On the other hand, the blue line says that 9 am. is my favorite time to wake up; the average time is 9:06 am.
How Fitbit calculates these times is a bit fuzzy for me – the only piece of documentation I found says that it determines the starting time when the person has not moved for around an hour. This rule implies that the data presented here do not show the actual time I spent sleeping, but luckily for me, Fitbit provides this magic number, and I'll display it on the following chart.
On average, I slept around 429.92 minutes or 7.16 hours every night. While it is not the recommended eight, it is a good step towards this goal :). Furthermore, if you take a look at June 18, you can clearly see that it was my best night; a well-deserved sleep after such a walk.
Atmospheric Pressure and Light Intensity values
Storytime: A few months ago, I had a problem. The issue was that I wanted to log the atmospheric pressure (for one of my experiments) of my current location using my mobile device (Android), and since I was aware that the phone (and yours too probably) had a barometer sensor, I went to Google Play Store looking for an app that does this. And sure, I found many apps that read sensor data and displays it on the screen. However, unfortunately, none of the apps offered the option to export the sensor data to an external file, while the app itself is running in the background. So, I wrote (and published) an app, and thanks to it, now I can continuously log and export the data from the various sensors my phone has.
In this section, I will present the atmospheric pressure data, measured in hectopascal (hPa) of the locations I have been, and the light intensity value, measured in lux (lx) as reported by my app.
Now you might be asking: "why is this important?" or "Why are you calculating this?" Good question. First, I am a data person, so I like to collect data (pretty sure you already deducted this). Second, and most importantly, I believe that this data can tell a bit more about the current conditions of the places I have been, adding a bit of "spice" to the story I'm saying. Good? Cool. Now, back at it.
I'll open this segment with a scatterplot that visualizes the atmospheric pressure registered by the app.
What we see here is that the pressure of the places I have visited is relatively the same – an average value of 884.06 hPa with a standard deviation of 21.54, implying that I have been around the same altitude (1135.1 m.). Of course, the only exception was on the hiking day; at the top of the mountain, the average pressure was 776.12 hPa. This value, when converted to pressure altitude, is 2191.7 m, a height that resembles the actual height of the peak (see how all the numbers match?!?!).
The second kind of sensor data I have been calculating is light intensity, a metric that essentially says how bright an area is. What prompted me to use this obscure, and honestly, kind of non-important, piece of data is to get an idea of how dark my days are, and to try to deduct the time I spent outdoors (because outside is brighter than indoors, duh).
For the next visualization, I'll introduce the median light intensity sensor readings per hour from the last couple of days. Moreover, to make the graph more insightful, I'll append to the same chart the median cloudiness level of the region I was at.
The blue line represents the lux (lx) value (in log scale), while the red one describes the cloudiness level (as a percentage). The exciting thing about the graph and the exact thing I wanted to discover is that logically, the cloudiness level is somehow inversely proportional to the light output score. But more than this silly groundbreaking revelation, this plot also shows that the best thing to do on sunny days is to go outside, enjoy the Sun, and maybe have a sweet BBQ in the woods.
Cute cow enjoying the good weather. By me.
While Spotify is not directly linked to anything "wander-ish" or "outdoor-ish," its data can tell a couple of things about my daily activities. To give a bit of background, for more than two years I have been heavily analyzing (and collecting through a service I wrote) my Spotify data and have discovered information such as my preferred style of music, favorite artists and even the times in which I don't listen to music. Therefore, I'm well aware of my musical patterns, and for this reason, I wanted to keep studying this data and see how it evolves during my journey.
I'll start this Spotify recap by showing the number of songs played by days and by the hour to understand what's my most musically active day and time of the day.
Since the last recap, I have listened to 123 songs, an average of 13.67 songs per day. Of these days, June 19 was the most active one while June 24 and 25 were the quiet days. What exactly was I listening? The next tables show my top songs and artists of this period.
|1||Tyler, The Creator||87||70.7|
|3||RUNNING OUT OF TIME||10||8.13|
|4||ARE WE STILL FRIENDS?||9||7.32|
|5||NEW MAGIC WAND||8||6.50|
|6||A BOY IS A GUN*||7||5.69|
|10||GONE, GONE / THANK YOU||6||4.88|
Tyler, The Creator, is numero uno. Of all the songs I heard during those nine days, 87 of them (70.7%) were by Tyler. On second place is GoldLink, followed by Apparat. Regarding the songs, the top 10 were from Tyler, but for those of you who are curious, GoldLink's most played song was U Say, an excellent musical piece that features...Tyler, The Creator, while Apparat song is Goodbye, the opening song from Netflix's show Dark (do yourself a favor and watch it).
Since I started traveling, I'm dedicating a couple of hours of my days to writing articles such as this one, and coding. To acquire focus and concentration, I open up the windows to admire the mountains surrounding me and plug in my headphones to block any external noise (and to listen to Tyler). Through the next plot that presents my preferred times, so we can get an idea of when I like to sit in from of the computer.
On this recap of my series Wander Data, I told and relived through Fitbit, Spotify and sensor data, some of my travel stories and events that occurred between June 16 and June 28, 2019. The main occasion of those days was the hike on June 18, and its effects could be seen in most of the graphs presented here.
Thanks for reading. If you have any questions, doubts, or just want to chat, leave me a comment, and I'll be happy to answer.
The code I used for this report is available at the wanderdata-scripts repo, available here: wanderdata-scripts.
The app Background Sensors is available at the following link: https://play.google.com/store/apps/details?id=com.juandes.sensors