Editing What does clustering tell us

Jump to navigation Jump to search

Warning: You are not logged in. Your IP address will be publicly visible if you make any edits. If you log in or create an account, your edits will be attributed to your username, along with other benefits.

The edit can be undone. Please check the comparison below to verify that this is what you want to do, and then save the changes below to finish undoing the edit.

Latest revision Your text
Line 129: Line 129:
 
|Total amount of time spent using apps classified as "very productive"
 
|Total amount of time spent using apps classified as "very productive"
 
|}
 
|}
The data was exported from the respective sources through the [[Open Humans]] integrations. A Jupyter notebook to export all this data in a unified spreadsheet is available<ref>https://exploratory.openhumans.org/notebook/169/</ref>.  
+
The data was exported from the respective sources through the [[Open Humans]] integrations. A Jupyter notebook to export all this data in a unified spreadsheet will be made available soon.
  
 
=== Processing the data ===
 
=== Processing the data ===
Line 137: Line 137:
  
 
== Running a PCA ==
 
== Running a PCA ==
With the full data table prepared for this time period, I ended up with 280 observations (aka days) that had full data for these 37 variables that I could use to run the PCA. For this I used the [[R]] package <code>FactoMineR</code> as it not only provides the basic functions for running the analysis, but also a wide set of visualization options<ref>A good tutorial can be found here: http://www.sthda.com/english/articles/31-principal-component-methods-in-r-practical-guide/112-pca-principal-component-analysis-essentials/</ref>. The code for running this analysis is online as well<ref>The R code is at the end of this notebook here: https://exploratory.openhumans.org/notebook/169/ (It won't run in the Open Humans notebook infrastructure due to some R-version issue. You will need to copy and paste it into your own R/RStudio environment). </ref>. Roughly speaking, PCAs are a way to reduce the dimensionality of data by 'rotating' the data in a way that it can be represented in fewer dimensions, ideally no more than 2-3 as this would allow visualizing it in a human-readable space. In this case, we have 37 different dimensions as given by the 37 variables and would like to boil it down to fewer dimensions without losing any information.   
+
[[File:PCA test variable alignment.png|thumb|The variable distribution after the PCA, answering how the 37 different variables correlate with each other. Arrows pointing in the same direction positively correlate with each other. Arrows pointing in opposite directions are negatively correlated. Length of the arrows is a metric for how 'well' the variable is represented in the PCA. Colors are the result of kmeans clustering of variables.]]
 +
With the full data table prepared for this time period, I ended up with 280 observations (aka days) that had full data for these 37 variables that I could use to run the PCA. For this I used the [[R]] package <code>FactoMineR</code> as it not only provides the basic functions for running the analysis, but also a wide set of visualization options. Roughly speaking, PCAs are a way to reduce the dimensionality of data by 'rotating' the data in a way that it can be represented in fewer dimensions, ideally no more than 2-3 as this would allow visualizing it in a human-readable space. In this case, we have 37 different dimensions as given by the 37 variables and would like to boil it down to fewer dimensions without losing any information.   
  
===How do the different metrics correlate?===
+
=== How do the different metrics correlate? ===
[[File:PCA test variable alignment.png|thumb|The variable distribution after the PCA, answering how the 37 different variables correlate with each other. Arrows pointing in the same direction positively correlate with each other. Arrows pointing in opposite directions are negatively correlated. Length of the arrows is a metric for how 'well' the variable is represented in the PCA. Colors are the result of kmeans clustering of variables.]]  Running the PCA – including a normalization/re-scaling of the variables – results in the graph on the right. Doing an additional clustering by kmeans shows that there are three main groups in which the variables can be clustered:   
+
Running the PCA – including a normalization/re-scaling of the variables – results in the graph on the right. Doing an additional clustering by kmeans shows that there are three main groups in which the variables can be clustered:   
  
#The '''top left quadrant''' mainly includes all metrics associated to productivity as measured by RescueTime (regardless of productivity/unproductivity category), as well as different metrics from Oura that relate to inactivity but also my cycling distance.
+
# The '''top left quadrant''' mainly includes all metrics associated to productivity as measured by RescueTime (regardless of productivity/unproductivity category), as well as different metrics from Oura that relate to inactivity but also my cycling distance.
#The '''bottom right quadrant''' includes mainly different sleep metrics from Oura but also associated metrics such as resting heart rate and average sleeping heart rate and furthermore my weight.
+
# The '''bottom right quadrant''' includes mainly different sleep metrics from Oura but also associated metrics such as resting heart rate and average sleeping heart rate and furthermore my weight.
#The '''top right quadrant''' includes metrics that have a 90º vector to both other clusters and mainly includes different metrics to medium & higher intensity activity. These include my overall step count as well as active calorie burn.
+
# The '''top right quadrant''' includes metrics that have a 90º vector to both other clusters and mainly includes different metrics to medium & higher intensity activity. These include my overall step count as well as active calorie burn.
  
The axis-labels also show how much of the overall variance in my data can be explained among these two dimensions that are being plotted, which comes down to 18.5% of variance on the X-axis (dimension 1) and 13.8% on the Y-axis (dimension 2). Together, the first three dimensions of the PCA [[:File:PCA explained variance.png|can explain around 44% of all the variance]] across the 37 variables.   
+
The axis-labels also show how much of the overall variance in my data can be explained among these two dimensions that are being plotted, which comes down to 18.5% of variance on the X-axis (dimension 1) and 13.8% on the Y-axis (dimension 2).   
 
+
{{Project Queries}}
===How do the different data points cluster across the first two dimensions?===
+
[[Category:Projects]]
These PCA results now also allow us to look at the different data points in this new coordinate system by plotting them across the first two dimensions as a scatter plot. Before doing so I decided to use the same kmeans-clustering approach to assign each data point one of two possible labels. This clustering shows that the first automatically assigned label broadly clusters to the top-left quadrant of the PCA, towards the metrics discussed above. The second clustering is found spread out more in the top and bottom right quadrants, covering the other metrics. Interestingly, doing the kmeans clustering with three target clusters does not split this larger cluster into two, but rather leads to a third cluster that broadly overlaps with the other two.
 
 
 
<gallery widths="500px" heights="300px">
 
File:PCA kmeans results.png|thumb|Visualizing the 280 days of data within the PCA system. Data points were clustered using kmeans to assign one of two labels in an unsupervised fashion.
 
File:PCA weekday labeling.png|thumb|Same PCA visualization but labeling each data point by whether it is a weekday or weekend day instead.
 
</gallery>
 
 
 
Given that the first clustering broadly aligns with metrics related to productivity and lack of physical activity while the second is driven by sleep and physical activity metrics, I assumed that this unsupervised split might be roughly indicative of the division between workdays and weekend days. To evaluate if that is the case I decided to use weekend/weekdays as labeling for the same type of visualization as done before using the kmeans approach. Overall, this split of the data comes out quite similar, though with a bit more of overlap than seen in the kmeans-clusters. Which might make sense, as the workday/weekend labeling is an imperfect proxy for whether I followed my normal workday routine of biking to the office, working there and then going home:
 
 
 
On holidays and when being sick, this routine will be broken despite it being a "normal" workday as per calendar. And on some weekend days I might work from home or from the office, making this distinction fuzzy in both directions. An interesting next step might be to look at those days which change their labels between the weekday/weekend-proxy and kmeans clustering to see if these 'classification errors' might indeed result from these factors.
 
 
 
== So what does it all tell us?! ==
 
When I started this, I was mainly wondering if I would find some interesting clustering of data when doing such an unsupervised clustering of data as performed here. I did expect to find a strong effect between 'weekend' and 'weekdays' but also hoped to maybe see some more subtle differences emerge that would be less obvious to myself. It seems to turn out that at least with this simplistic approach such a more-fine grained signal (if there is one) would be drowned out by the main factor of whether it's a day in the office or not.
 
 
 
I tried to account for this big signal by filtering out all days which fall on weekends, but the results didn't really change overall. Coming to think of it now this seems to partially be due to the impact of homeoffice/holidays/sickness that makes a weekday filtering only a rough proxy for the routines that took place. A potential approach to account for this might be to add my [[Overland]] GPS data into the mix to see whether I went to the office or not. Generally, adding GPS data might be able to provide a strong signal beyond showing presence/absence in the office, e.g. by summing up the total distance traveled on that day or other movement metrics that go beyond walking/biking as measured by my Apple Watch/Oura Ring.
 
 
 
Lastly, the very strong correlation of the variables into three main clusters in the PCA is quite interesting in itself as well as how they are or aren't correlated to each other. In particular the negative correlation between the various sleep metrics and the productivity & inactivity metrics is quite interesting to see. Not only does it make some intuitive sense to me, but it is equally interesting that the medium-high physical activity variables are nearly 90º rotated away from either of them, indicating a lack of correlation between those and any other of the metrics. I'm not fully sure how to interpret it, but given the labeling of the data points it might be a sign that whether I go to work or not doesn't have too much of an effect on higher levels of physical activity, rather workdays might only influence how much ''inactive/low-activity'' time I accumulate?
 
 
 
== References ==
 
<references />
 
 
 
[[Category:Projects]][[Category:Productivity projects]][[Category:Sleep projects]][[Category:Diet, digestion and weight loss projects]]
 

Please note that all contributions to Personal Science Wiki are considered to be released under the Creative Commons Attribution-ShareAlike 3.0 Unported (see PersonalScienceWiki:Copyrights for details). If you do not want your writing to be edited mercilessly and redistributed at will, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource. Do not submit copyrighted work without permission!

Cancel Editing help (opens in new window)

Template used on this page: