{"id":1761,"date":"2022-09-05T08:00:00","date_gmt":"2022-09-05T06:00:00","guid":{"rendered":"https:\/\/www.manuelmontanari.com\/blog\/?p=1761"},"modified":"2022-09-05T08:04:38","modified_gmt":"2022-09-05T06:04:38","slug":"data-preparation","status":"publish","type":"post","link":"https:\/\/www.manuelmontanari.com\/blog\/data-preparation\/","title":{"rendered":"Data Preparation"},"content":{"rendered":"\n<p>In my previous post about <a href=\"https:\/\/www.manuelmontanari.com\/blog\/data-visualization\/\" target=\"_blank\" rel=\"noreferrer noopener\">data visualization<\/a> I have focused on different ways to present a dataset, however a very important aspect that we always underestimate and do not consider as fundamental is the data preparation one. It is widely known that a data scientist spends most of his working time preparing data (a safe assumption is that around 80% of the total time is spent executing data preparation tasks).<\/p>\n\n\n\n<p>So i wanted to verify this by going through a practical exercises. I had first to find a nice dataset to work with. Lukyly i have an iPhone where i&#8217;m keeping track of my daily weight since late 2014 so i thought it would be a good exercise to see what i could do with that data i already have (and own).<\/p>\n\n\n\n<p>fisrt i had to export the data from my phone (data gathering task, aka collecting the datasets).<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/IMG_7605.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/IMG_7605-513x1024.jpg\" alt=\"\" class=\"wp-image-1763\" width=\"257\" height=\"512\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/IMG_7605-513x1024.jpg 513w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/IMG_7605-150x300.jpg 150w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/IMG_7605-768x1533.jpg 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/IMG_7605-770x1536.jpg 770w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/IMG_7605-1026x2048.jpg 1026w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/IMG_7605-297x593.jpg 297w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/IMG_7605.jpg 1170w\" sizes=\"(max-width: 257px) 100vw, 257px\" \/><\/a><\/figure><\/div>\n\n\n<p>The iOS health export generates a ZIP file with all my Health data: a big XML file that contains a lot of not needed rows for the purpose of this specific data-crunching exercise. I do not need the steps, nor the run distance, I just need my daily weight.<\/p>\n\n\n\n<p>The first choice i have to make is: do i need to prepare all the dataset or should i create a subset to work with? it all depends on what i plan to do in the future. Will I only ever need my weight data or maybe tomorrow i will need to look at, say, steps per day for running a cross analysis later? For the purpose of today exercise i will only keep the weight data.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/export-size.jpg\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/export-size-1024x178.jpg\" alt=\"\" class=\"wp-image-1764\" width=\"256\" height=\"45\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/export-size-1024x178.jpg 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/export-size-300x52.jpg 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/export-size-768x134.jpg 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/export-size-1080x190.jpg 1080w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/export-size-297x52.jpg 297w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/export-size.jpg 1092w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><\/figure><\/div>\n\n\n<p>Looking at the XML file we first need to understand the label of the weight data we need:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/dataset1.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/dataset1-970x1024.png\" alt=\"\" class=\"wp-image-1770\" width=\"728\" height=\"768\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/dataset1-970x1024.png 970w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/dataset1-284x300.png 284w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/dataset1-768x810.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/dataset1-1456x1536.png 1456w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/dataset1-297x313.png 297w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/dataset1.png 1850w\" sizes=\"(max-width: 728px) 100vw, 728px\" \/><\/a><\/figure><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodymassindex.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"109\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodymassindex-1024x109.png\" alt=\"\" class=\"wp-image-1765\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodymassindex-1024x109.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodymassindex-300x32.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodymassindex-768x82.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodymassindex-1536x164.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodymassindex-2048x219.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodymassindex-297x32.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>the &#8220;HKQuantityTyoeIdentifierBodyMassIndex&#8221; is not the weight but the BMI (Body Mass Index), so we are lucky that the label is verbose and we can easily understand the data it contains. If that was not the caee, we could explore the data and try to guess the data type from the value itself (and in this case notice that health stores the BMi with a percentage with 4 decimal digits).<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodyweight-record.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"65\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodyweight-record-1024x65.png\" alt=\"\" class=\"wp-image-1766\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodyweight-record-1024x65.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodyweight-record-300x19.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodyweight-record-768x49.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodyweight-record-1536x98.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodyweight-record-2048x131.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/bodyweight-record-297x19.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Scrolling down we then spot the &#8220;HKQuantityTyoeIdentifierBodyMass&#8221; (was it too easy to simply call it &#8220;Weight&#8221;?). This is the values we are looking for. But how do i convert XML data into a more portable and compatible CSV format? It is a simple matter of googling the right words, maybe someone has already faced this specific problem and there is some documentation out there waiting to be found. So i came across the website <a rel=\"noreferrer noopener\" href=\"https:\/\/www.ericwolter.com\/projects\/apple-health-export\/\" target=\"_blank\">https:\/\/www.ericwolter.com\/projects\/apple-health-export\/ <\/a> that allows to upload the xml just exported from my iPhone health app and convert it to CSV. You can even select which data you are willing to export:<\/p>\n\n\n\n<p><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/apple-xml-converter.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"597\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/apple-xml-converter-1024x597.png\" alt=\"\" class=\"wp-image-1767\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/apple-xml-converter-1024x597.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/apple-xml-converter-300x175.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/apple-xml-converter-768x447.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/apple-xml-converter-1536x895.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/apple-xml-converter-297x173.png 297w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/apple-xml-converter.png 2046w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">The apple health export web tool<\/figcaption><\/figure><\/div>\n\n\n<p>in a matter of seconds the browser downloads the CSV files. I don\u2019t really care about the privacy of my health data, but if i was i would be careful to upload files to 3rd party sites. Anyways, here is the final size of the converted data that is needed:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converted-files.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converted-files-1024x120.png\" alt=\"\" class=\"wp-image-1768\" width=\"512\" height=\"60\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converted-files-1024x120.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converted-files-300x35.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converted-files-768x90.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converted-files-297x35.png 297w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converted-files.png 1140w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a><figcaption class=\"wp-element-caption\">The CSV files sized<\/figcaption><\/figure><\/div>\n\n\n<p>The biggest dataset is the step count file, but as explained today i want to focus on the weight, so i need the 207K byte csv file. It contains all my weight dataset from December 11th 2014.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converteddataset_CSV.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"439\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converteddataset_CSV-1024x439.png\" alt=\"\" class=\"wp-image-1789\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converteddataset_CSV-1024x439.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converteddataset_CSV-300x129.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converteddataset_CSV-768x329.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converteddataset_CSV-1536x659.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converteddataset_CSV-2048x878.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/converteddataset_CSV-297x127.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">The exported CSV files from the converter<\/figcaption><\/figure><\/div>\n\n\n<p>Now we need to transform and enrich the data according to the type of analysis we want to run. In my case i would like to understand from the data if there is a correlation between my weight and the day of the week (i have an idea that i want to confirm with the data). Am i eating more during weekends? this would emerge as a pattern if, for example, i notice that the average weight on mondays is higher then the other days of the week. So in order to run this type of analysis i need to have a date field but also a weekday field. This information can be easily added with a simple excel formula: <\/p>\n\n\n\n<p>weekday().<\/p>\n\n\n\n<p>Here is the Google Sheet i&#8217;ve amended from the CSV output generated with the XML converter. <a href=\"https:\/\/docs.google.com\/spreadsheets\/d\/1IIny5ScoEDrExtnsuhfg62lo69tNkwxhDKd9cqz4OVk\/edit?usp=sharing\">https:\/\/docs.google.com\/spreadsheets\/d\/1IIny5ScoEDrExtnsuhfg62lo69tNkwxhDKd9cqz4OVk\/edit?usp=sharing<\/a>. Since i don&#8217;t want to focus my analysis on the time of the day (that&#8217;s when i used the scale to weight myself, but it would include some more datapoints that maybe at this stage of my analysis are not really needed, so for the moment i&#8217;ll skip this data). Timezone is a redundant data since it&#8217;s always the same. So the columns i&#8217;ll need are the ones in green:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/google_sheet.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/google_sheet-936x1024.png\" alt=\"\" class=\"wp-image-1790\" width=\"468\" height=\"512\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/google_sheet-936x1024.png 936w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/google_sheet-274x300.png 274w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/google_sheet-768x840.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/google_sheet-1404x1536.png 1404w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/google_sheet-297x325.png 297w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/google_sheet.png 1486w\" sizes=\"(max-width: 468px) 100vw, 468px\" \/><\/a><figcaption class=\"wp-element-caption\">Amended CSV file (Google Sheets)<\/figcaption><\/figure><\/div>\n\n\n<p>Now that I prepared the dataset, i can choose the viz tool to be used. Since i have a Google sheet it\u2019s kind of straightforward to use Google Data Studio. So now we can move to the Google DataStudio front end and prepare our dataset, creating a new data connector, the CSV one in my case, and defining the data types:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-import-new-dataset.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"529\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-import-new-dataset-1024x529.png\" alt=\"\" class=\"wp-image-1773\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-import-new-dataset-1024x529.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-import-new-dataset-300x155.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-import-new-dataset-768x397.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-import-new-dataset-297x153.png 297w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-import-new-dataset.png 1328w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Google Data Studio &#8211; new data connection setup screen<\/figcaption><\/figure><\/div>\n\n\n<p>It is important to notice some facts from our dataset: there are missing datapoints (some days i am not at home so i don&#8217;t weight myself at all) and there are some days where i weighted myself multiple times in the same day. So we need to keep this two facts and configure the dataset and the data visualization accordinly. For example we don&#8217;t want the analysis to SUM the multiple weights on the same day (otherwise the total weight will be the double as the real one). We can choose to create an average between all the values for the same day, or we can take the lowest or highest value, or even choose to consider only the first data of the day); also we want to make sure that during the data visualization phase, missing data is taken into account, eigher by not including the missing days, or interpolating the data from the existing datasets.<\/p>\n\n\n\n<p>Google Data Studio offers the ability to choose the default aggregation type for our weight dimension, so we can choose &#8220;Average&#8221; instead of sum (&#8220;Media&#8221; in my italian language version). We&#8217;ll take care of the missing datasets later on when we define the chart visualization options:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-full is-resized\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-35.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-35.png\" alt=\"\" class=\"wp-image-1792\" width=\"315\" height=\"344\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-35.png 420w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-35-275x300.png 275w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-35-297x324.png 297w\" sizes=\"(max-width: 315px) 100vw, 315px\" \/><\/a><figcaption class=\"wp-element-caption\">Google Data Studio &#8211; Graph styling option missing data interpolation<\/figcaption><\/figure><\/div>\n\n\n<p> So, fast forward skipping the dashboard preparation (since this post is about data preparation) let&#8217;s see if we can get an insightfull dashboard: <a href=\"https:\/\/datastudio.google.com\/s\/uCrKw98vy_Q\">https:\/\/datastudio.google.com\/s\/uCrKw98vy_Q<\/a><\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-DASH1.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"754\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-DASH1-1024x754.png\" alt=\"\" class=\"wp-image-1769\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-DASH1-1024x754.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-DASH1-300x221.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-DASH1-768x565.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-DASH1-1536x1130.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-DASH1-2048x1507.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/GDS-DASH1-297x219.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Google Data Studio dashboard<\/figcaption><\/figure><\/div>\n\n\n<p>What I&#8217;m very happy with: the average weight KPI that shows the average weight calculated dinamically for the selected time period, and uses different colors depending on the value:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/kpis.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/kpis-1024x382.png\" alt=\"\" class=\"wp-image-1794\" width=\"256\" height=\"96\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/kpis-1024x382.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/kpis-300x112.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/kpis-768x287.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/kpis-1536x574.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/kpis-297x111.png 297w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/kpis.png 1912w\" sizes=\"(max-width: 256px) 100vw, 256px\" \/><\/a><figcaption class=\"wp-element-caption\">Google Data Studio: KPI visualization<\/figcaption><\/figure><\/div>\n\n\n<p>I&#8217;m also happy with the daily trend visualization, that eliminates the missing data points with linear interpolation, showing a nice uninterrupted trend line, with a goal weight line as refernce:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/daily-trend-with-optimized-axis.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"482\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/daily-trend-with-optimized-axis-1024x482.png\" alt=\"\" class=\"wp-image-1795\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/daily-trend-with-optimized-axis-1024x482.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/daily-trend-with-optimized-axis-300x141.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/daily-trend-with-optimized-axis-768x362.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/daily-trend-with-optimized-axis-1536x723.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/daily-trend-with-optimized-axis-2048x964.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/daily-trend-with-optimized-axis-297x140.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Google Data Studio: daily trend visualization with weight goal line reference<\/figcaption><\/figure>\n\n\n\n<p>I also added an analysis to show the average weight per weekday. Being able to adjust the X and Y axis scales is a very convenient option to hilight data differences in a graph (but i&#8217;m still not sure if the weekday formula I used converts Mondays into 1 or 2). I had a doubt that 1 stands for Sunday and 2 for Mondays, so i had to goolge it to confirm. So the weekday with the highest weight average for me is Monday. Data confirms my assumption: it&#8217;s more likely we party over weekends, or dine at partent&#8217;s and so on, therefore Mondays are more likely to have a higher weight:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weekday.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"419\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weekday-1024x419.png\" alt=\"\" class=\"wp-image-1796\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weekday-1024x419.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weekday-300x123.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weekday-768x314.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weekday-1536x628.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weekday-2048x838.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weekday-297x121.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>What i\u2019m not very happy with: I tried in several ways to create a staked columns chart to explore the data by weekday (and days) aggregating all dataset into 7 different facets but with not much success. Here is some failed visualizations i came up with (nice to see but not very insightfull):<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/data-aggregation-by-weight-range.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"414\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/data-aggregation-by-weight-range-1024x414.png\" alt=\"\" class=\"wp-image-1793\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/data-aggregation-by-weight-range-1024x414.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/data-aggregation-by-weight-range-300x121.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/data-aggregation-by-weight-range-768x311.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/data-aggregation-by-weight-range-1536x622.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/data-aggregation-by-weight-range-2048x829.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/data-aggregation-by-weight-range-297x120.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Google Data Studio: Bubble chart with weight and weekdays and hours (!)<\/figcaption><\/figure><\/div>\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/days-weekday-color-1.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"411\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/days-weekday-color-1-1024x411.png\" alt=\"\" class=\"wp-image-1798\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/days-weekday-color-1-1024x411.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/days-weekday-color-1-300x121.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/days-weekday-color-1-768x309.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/days-weekday-color-1-1536x617.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/days-weekday-color-1-2048x823.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/days-weekday-color-1-297x119.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Google Data Studio: bar chart with days and weight and weekday represented by colour<\/figcaption><\/figure>\n\n\n\n<p>So i decided to switch for another approach: i could import my waight data into Mapp Intelligence, defining a new Time Category parameter (a KPI that can be imported into Mapp Intelligence using the TIME as key field) and see where i can get to from there. But first of course I need to define a new Time Category dimension. For clarity I called it &#8220;weight&#8221;:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/Time-Category-Setup.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"342\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/Time-Category-Setup-1024x342.png\" alt=\"\" class=\"wp-image-1774\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/Time-Category-Setup-1024x342.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/Time-Category-Setup-300x100.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/Time-Category-Setup-768x256.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/Time-Category-Setup-1536x513.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/Time-Category-Setup-2048x684.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/Time-Category-Setup-297x99.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Then once created i can easily import the dataset by creating a CSV file with the needed format. Here is more data preparation task, as Mapp Intelligence requires the time column to be formatted as YYYY-MM-DD HH). Once formatted here is the input CSV file prepared for the data import:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/import-MI.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"400\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/import-MI-1024x400.png\" alt=\"\" class=\"wp-image-1776\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/import-MI-1024x400.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/import-MI-300x117.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/import-MI-768x300.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/import-MI-297x116.png 297w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/import-MI.png 1437w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Note that here i don\u2019t need to import any weekday value since Mapp Intelligence has a dedicated dimension already in place that derives the value from the imported time stamp. Now I need to wait for Mapp Intelligence to import the dataset. This process takes place every hour or so, since in the meantime the system processes also the Website data it is programmed to collect.<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large is-resized\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/waiting.png\"><img decoding=\"async\" loading=\"lazy\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/waiting-1024x180.png\" alt=\"\" class=\"wp-image-1775\" width=\"512\" height=\"90\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/waiting-1024x180.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/waiting-300x53.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/waiting-768x135.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/waiting-297x52.png 297w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/waiting.png 1414w\" sizes=\"(max-width: 512px) 100vw, 512px\" \/><\/a><\/figure><\/div>\n\n\n<p>Now before using the imported data I need to specify the aggregation type for the metric. By default it is a sum, so I need to create a new one that calculates the average instead. For doing this in Mapp Intelligence I\u2019ll simply need to create a new custom formula and save it:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/custom-formua.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"627\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/custom-formua-1024x627.png\" alt=\"\" class=\"wp-image-1799\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/custom-formua-1024x627.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/custom-formua-300x184.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/custom-formua-768x470.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/custom-formua-1536x941.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/custom-formua-297x182.png 297w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/custom-formua.png 1786w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Mapp Intelligence &#8211; Custom Formula creation<\/figcaption><\/figure><\/div>\n\n\n<p>In the custom formula editor I can also specify the target value (min or max) so that the the target is green and the opposite is red in the data visualization with traffic lights when showing the data in a table:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/trafficlights.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"146\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/trafficlights-1024x146.png\" alt=\"\" class=\"wp-image-1801\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/trafficlights-1024x146.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/trafficlights-300x43.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/trafficlights-768x109.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/trafficlights-1536x219.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/trafficlights-2048x292.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/trafficlights-297x42.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Mapp Intelligence: table visualization with traffic lights<\/figcaption><\/figure>\n\n\n\n<p>Unfortunately with time dimensions is not possible to hide missing values or interpolate them to cover the gaps, so if they missing data really bothers me i\u2019d have to go back to the data preparation phase and manually interpolate the missing data, or automate the task with an R or Python script, for example.<\/p>\n\n\n\n<p>Anyways, once created the average imported weight metric, the final result for the visualization is closer to what i wanted to get: a visual heatmap of the entire dataset. <\/p>\n\n\n\n<p>Here are some different experiments using different time intervals: this are all monthly aggregations (Y axis) split by weekdays (X axis) so that each weekday value is the average of all the same weekdays for that month, not the sum:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-2.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"621\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-2-1024x621.png\" alt=\"\" class=\"wp-image-1777\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-2-1024x621.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-2-300x182.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-2-768x466.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-2-1536x932.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-2-2048x1242.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-2-297x180.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>As we can see the cross-tab visualization is very useful as it automatically puts the heatmap colour in scale for the entire dataset, and we can clearly spot outliers and derive insights in a clear and visual way:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"310\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-1024x310.png\" alt=\"\" class=\"wp-image-1778\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-1024x310.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-300x91.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-768x233.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-1536x466.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-2048x621.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/weight-by-weekday-and-months-297x90.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>for example by looking at this cross-table we can easily spot that the &#8220;hottest&#8221; (heavy weight) months are the winter ones, especially January (after the winter holidays).<\/p>\n\n\n\n<p>If we plot 5 years of data the pattern is cristal clear:<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/crosstable-5-years.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"565\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/crosstable-5-years-1024x565.png\" alt=\"\" class=\"wp-image-1802\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/crosstable-5-years-1024x565.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/crosstable-5-years-300x165.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/crosstable-5-years-768x423.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/crosstable-5-years-1536x847.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/crosstable-5-years-2048x1129.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/crosstable-5-years-297x164.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>in the past couple of years the pattern has slightly changes (less parties during weekends, yes, that&#8217;s right) and less winter holidays dinners. But as we can see this graphical representation really gives a lot of insights to understand the data.<\/p>\n\n\n\n<p>I also wanted to explore some additional data visualization in R, since some statistical approach could help as well. So i spent some time adjusting the data to an R  friendly datasource:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-37.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"640\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-37-1024x640.png\" alt=\"\" class=\"wp-image-1827\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-37-1024x640.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-37-300x188.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-37-768x480.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-37-1536x961.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-37-2048x1281.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-37-436x272.png 436w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-37-297x186.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">R &#8211; Data transformation code<\/figcaption><\/figure><\/div>\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-38.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"637\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-38-1024x637.png\" alt=\"\" class=\"wp-image-1828\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-38-1024x637.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-38-300x186.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-38-768x477.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-38-1536x955.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-38-2048x1273.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-38-436x272.png 436w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-38-297x185.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">R &#8211; Time series plot<\/figcaption><\/figure><\/div>\n\n\n<p>So i wanted to plot the weight distribution by day of the week, to hilight which days have bigger or smaller variance (to find out the actual variance is not significant between 2014 and 2022): <\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>plot &lt;- ggplot(data=peso3, aes(x=giorno, y=peso, colour=giorno))\n        + geom_jitter(size=0.1) \n        + geom_boxplot(size=0.1, alpha=0.6) \n        + ggtitle(\"Weight by Weekday and Year\")\n        + facet_grid(Year~.)<\/code><\/pre>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-39.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"624\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-39-1024x624.png\" alt=\"\" class=\"wp-image-1829\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-39-1024x624.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-39-300x183.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-39-768x468.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-39-1536x936.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-39-2048x1248.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-39-297x181.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<p>Also this visualization demonstrates how the &#8220;mondays&#8221; have an higher average weight. The interesting part is adding facets per year, so that the variance in each year can be compared:<\/p>\n\n\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-40.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"627\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-40-1024x627.png\" alt=\"\" class=\"wp-image-1830\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-40-1024x627.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-40-300x184.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-40-768x470.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-40-1536x940.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-40-2048x1254.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-40-297x182.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure><\/div>\n\n\n<p>The biggest variance is in 2015, where I lost the majority of my over-weight.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-41.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"219\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-41-1024x219.png\" alt=\"\" class=\"wp-image-1831\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-41-1024x219.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-41-300x64.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-41-768x164.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-41-1536x328.png 1536w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-41-2048x438.png 2048w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-41-297x63.png 297w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><\/figure>\n\n\n\n<p>Long story short, it took me about 10 hours of total work this exercise (excluding the time to write this post about it) during my summer holidays. Of those, about 7 hours were spent for data extrapolation, transformation and load, and a couple of hours experimenting with visualization methods. This means in my case 70% of the time was spent in data preparation and 30% in analysis, however i did have to experiment a bit with some features i was not alerady familiar with, therefore i assume that next round it would probabily be more aligned to the 80\/20 split that is belived to be the average.<\/p>\n\n\n\n<p>The <strong>next chapter<\/strong> for this analysis should be adding the steps information to the dataset and using that as secondary KPI to find correlation between weight-loss and number of daily steps, for example and see if there is any correlation. Remembering that <strong>correlation does not mean causality<\/strong>, but i&#8217;ll leave this topic for <strong>a future series of posts about cognitive and data biases<\/strong>. Stay tuned since next monday!!!<\/p>\n\n\n\n<p>Have a good week and happy analysis!<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><a href=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/flawed_data_2x.png\"><img decoding=\"async\" loading=\"lazy\" width=\"1024\" height=\"428\" src=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/flawed_data_2x-1024x428.png\" alt=\"\" class=\"wp-image-1804\" srcset=\"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/flawed_data_2x-1024x428.png 1024w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/flawed_data_2x-300x125.png 300w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/flawed_data_2x-768x321.png 768w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/flawed_data_2x-297x124.png 297w, https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/flawed_data_2x.png 1159w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/a><figcaption class=\"wp-element-caption\">Copyright https:\/\/xkcd.com\/2494\/<\/figcaption><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>In my previous post about data visualization I have focused on different ways to present a dataset, however a very important aspect that we always underestimate and do not consider as fundamental is the data preparation one. It is widely known that a data scientist spends most of his working [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":1827,"comment_status":"closed","ping_status":"open","sticky":true,"template":"","format":"standard","meta":{"footnotes":"","_jetpack_memberships_contains_paid_content":false},"categories":[181,30,182],"tags":[272,281,280,98,279,99,270,271,274,282,107,275,276,278,283,277,206,273],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"https:\/\/www.manuelmontanari.com\/blog\/wp-content\/uploads\/2022\/08\/image-37.png","jetpack-related-posts":[],"_links":{"self":[{"href":"https:\/\/www.manuelmontanari.com\/blog\/wp-json\/wp\/v2\/posts\/1761"}],"collection":[{"href":"https:\/\/www.manuelmontanari.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.manuelmontanari.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.manuelmontanari.com\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.manuelmontanari.com\/blog\/wp-json\/wp\/v2\/comments?post=1761"}],"version-history":[{"count":20,"href":"https:\/\/www.manuelmontanari.com\/blog\/wp-json\/wp\/v2\/posts\/1761\/revisions"}],"predecessor-version":[{"id":1848,"href":"https:\/\/www.manuelmontanari.com\/blog\/wp-json\/wp\/v2\/posts\/1761\/revisions\/1848"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.manuelmontanari.com\/blog\/wp-json\/wp\/v2\/media\/1827"}],"wp:attachment":[{"href":"https:\/\/www.manuelmontanari.com\/blog\/wp-json\/wp\/v2\/media?parent=1761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.manuelmontanari.com\/blog\/wp-json\/wp\/v2\/categories?post=1761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.manuelmontanari.com\/blog\/wp-json\/wp\/v2\/tags?post=1761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}