Fitbit stats project.
It’s done, I submitted the project on Friday!
It took a little bit to get the time axes. There was an exercise from the minicourse problem sets that said how to do it, but I still had to Google around to get the information I wanted. This site was the most helpful. For the monthly graphs, I wanted the tick marks to be one-letter abbreviations for the days of the week. I wasn’t able to format those axes right until Matt’s last office hours on Friday. He had suggested before that I make a function that maps the numerical day of the week (0-6) to its abbreviation. This was hard to do because my axis function isn’t bound to the data and so I didn’t know what to put for the input. Matt helped me to determine what my variable d
was, it turns out it was just the date of the data point. So given my array week
with the abbreviations, I was able to make the following function under tickFormat
:
.tickFormat(function(d){
return week[d.getDay()]
})
The final project just has my exercise for the year, and my resting heartrate and sleep score as functions of exercise. I tried to set up the selector to toggle all the graphs at the same time, but it turns out it was much easier to make a separate selector for each section, which is what I wanted to do in the first place. I really wish I’d had time to do more. Especially in the “Exercise” section, I wanted to break each bar down into the instances of exercise (for example, if I went to the gym and walked to campus on the same day), then further by heartrate zones. I did spend some time trying to do that, but it was very hard because each day had a different number of instances of exercise. Then I tried to do something similar, but simpler, with the sleep score data. Sleep score is broken down into three subcomponents, which I wanted to show on the graphs, but it was still something I couldn’t figure out in time to submit the project.
Even though I didn’t get to do everything I wanted, I was very proud of what I submitted (at the time – I looked at the descriptions of the other projects and they seemed more ambitious, and then I just found out this morning that my video presentation has no sound!). The easiest part was formatting the page to look pretty with CSS. I just copied what I did for my Arkansas website and modified it a little bit. Matt said the project was good enough to showcase what I know how to do with html, CSS, and JavaScript, but he also said I could improve it as much as I want later. I want to, even though I don’t know when I’ll have time to. There is one glaring mistake in the graphs that I want to address first: the graphs of heartrate and sleep score only have data on dates when I exercised. I think this was a mistake in how I cleaned the data, so it’ll take some time to figure out exactly what I did wrong and how to fix it. My dad also asked me if the heartrate data had been discretized by Fitbit. He said the graph would look more organic if it was a continuous graph instead of a bar chart. As far as I know, Fitbit only has one resting heartrate per day but even with that I could make the graph into a line plot to show it’s a continuous variable. Matt also suggested I make a plot of my average amount of exercise for each day of the week.
Now that I’m done with this project (for now, I guess) I need to get back to the 538 project. I’d told myself I would give myself a week to finish it after submitting the Fitbit stats project but since Friday I haven’t done anything. I think I really needed the break. Matt said next I should run a clustering algorithm on the data. Clustering is another unsupervised learning technique that I need to learn about. I’ll get to it soon. I’d like to have that project done by the end of this month.