NYC Data Science Academy| Blog
Bootcamps
Lifetime Job Support Available Financing Available
Bootcamps
Data Science with Machine Learning Flagship 🏆 Data Analytics Bootcamp Artificial Intelligence Bootcamp New Release 🎉
Free Lesson
Intro to Data Science New Release 🎉
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook Graduate Outcomes Must See 🔥
Alumni
Success Stories Testimonials Alumni Directory Alumni Exclusive Study Program
Courses
View Bundled Courses
Financing Available
Bootcamp Prep Popular 🔥 Data Science Mastery Data Science Launchpad with Python View AI Courses Generative AI for Everyone New 🎉 Generative AI for Finance New 🎉 Generative AI for Marketing New 🎉
Bundle Up
Learn More and Save More
Combination of data science courses.
View Data Science Courses
Beginner
Introductory Python
Intermediate
Data Science Python: Data Analysis and Visualization Popular 🔥 Data Science R: Data Analysis and Visualization
Advanced
Data Science Python: Machine Learning Popular 🔥 Data Science R: Machine Learning Designing and Implementing Production MLOps New 🎉 Natural Language Processing for Production (NLP) New 🎉
Find Inspiration
Get Course Recommendation Must Try 💎 An Ultimate Guide to Become a Data Scientist
For Companies
For Companies
Corporate Offerings Hiring Partners Candidate Portfolio Hire Our Graduates
Students Work
Students Work
All Posts Capstone Data Visualization Machine Learning Python Projects R Projects
Tutorials
About
About
About Us Accreditation Contact Us Join Us FAQ Webinars Subscription An Ultimate Guide to
Become a Data Scientist
    Login
NYC Data Science Acedemy
Bootcamps
Courses
Students Work
About
Bootcamps
Bootcamps
Data Science with Machine Learning Flagship
Data Analytics Bootcamp
Artificial Intelligence Bootcamp New Release 🎉
Free Lessons
Intro to Data Science New Release 🎉
Find Inspiration
Find Alumni with Similar Background
Job Outlook
Occupational Outlook
Graduate Outcomes Must See 🔥
Alumni
Success Stories
Testimonials
Alumni Directory
Alumni Exclusive Study Program
Courses
Bundles
financing available
View All Bundles
Bootcamp Prep
Data Science Mastery
Data Science Launchpad with Python NEW!
View AI Courses
Generative AI for Everyone
Generative AI for Finance
Generative AI for Marketing
View Data Science Courses
View All Professional Development Courses
Beginner
Introductory Python
Intermediate
Python: Data Analysis and Visualization
R: Data Analysis and Visualization
Advanced
Python: Machine Learning
R: Machine Learning
Designing and Implementing Production MLOps
Natural Language Processing for Production (NLP)
For Companies
Corporate Offerings
Hiring Partners
Candidate Portfolio
Hire Our Graduates
Students Work
All Posts
Capstone
Data Visualization
Machine Learning
Python Projects
R Projects
About
Accreditation
About Us
Contact Us
Join Us
FAQ
Webinars
Subscription
An Ultimate Guide to Become a Data Scientist
Tutorials
Data Analytics
  • Learn Pandas
  • Learn NumPy
  • Learn SciPy
  • Learn Matplotlib
Machine Learning
  • Boosting
  • Random Forest
  • Linear Regression
  • Decision Tree
  • PCA
Interview by Companies
  • JPMC
  • Google
  • Facebook
Artificial Intelligence
  • Learn Generative AI
  • Learn ChatGPT-3.5
  • Learn ChatGPT-4
  • Learn Google Bard
Coding
  • Learn Python
  • Learn SQL
  • Learn MySQL
  • Learn NoSQL
  • Learn PySpark
  • Learn PyTorch
Interview Questions
  • Python Hard
  • R Easy
  • R Hard
  • SQL Easy
  • SQL Hard
  • Python Easy
Data Science Blog > Capstone > Data visualization on activity tracking device

Data visualization on activity tracking device

Kawtar B
Posted on Mar 3, 2016
The skills the author demoed here can be learned through taking Data Science with Machine Learning bootcamp with NYC Data Science Academy.

I. Introduction

Nowadays, there are wide selections and different price options for wearable activity tracking devices, or “wearables”. Most of these tracking devices harness a 3-axis accelerometer to understand the user’s motions. By analyzing acceleration data, the trackers provide information about frequency, duration, intensity, and patterns of movement to determine a multitude of health metrics, such as steps taken, distance traveled, calories burned, and sleep quality.

Another advantage of owning this device for data and fitness enthusiasts is the ability to log their food, activities, and weight over time with the possibility to set daily and weekly goals for themselves for steps, calories burned and distance walked. One of the most popular wearable tracking devices is Fitbit. Like most wearable activity tracking devices,  there is the option to synchronize your data to your user account via Fitbit Connect. In this work, we consider Steps as our health and fitness goal that we wish to predict.

II. The Data

Fitbit users can extract their data by logging into their Fitbit Connect account as shown in Fig.1 below, where data for one year of activities and sleep could be extracted in CSV format.

Data visualization on activity tracking device

Fig. 1 : Data Extraction for Fitbit user’s webpage

After gathering a one year activities and sleep data, an exploratory data analysis is achieved using Python in order to determine the assess the relationship or determine the patterns between different type of measurements from May 8 2015 to May 7 2016. For each day, the extracted data has the following features (columns of our datasets):

  • Calorie burned
  • Steps
  • Distance
  • Floors
  • Sedentary Minutes 
  • Lightly Active Minutes 
  • Fairly Active Minutes 
  • Very Active Minutes 
  • Activity Calories
  • Minutes of Sleep
  • Minutes of Being Awake
  • Number of Awakenings
  • Length Of Rest In Minutes

III. Exploratory data analysis

First we take a look to the distribution of our raw data as shown in Fig.2 below.

Data visualization on activity tracking device Data visualization on activity tracking device capstone_nyc-ipynb

Fig. 2 : Raw Data

Based on the raw data from Fig.2, we can see the following:

  • There are no missing values in the dataset
  • Some of the data are zero, this is because Fitbit is not worn, is charging or due to some failures in synchronizing the data
  • Sedentary minutes are longer than activity minutes
  • Light activity has a distribution that resembles the gaussian distribution
  • There are less minutes fairly active or very active days. Distribution appear as a log normal distribution
  • Floors feature describes elevation or climbing and seems to have a log normal distribution
  • On average Sleep is around 5 to 6 hours
  • Daily Steps vary between 5000 and 20000 steps equivalent to a distance up to 12 miles

In this dataset, we distinguish 3 types of health or fitness goals: Steps, Calories burned, Hours of Sleep, and Sleep efficiency. To assess the sleep quality for a specific day, we define Sleep efficiency as the percentage of Minutes of Sleep over Length Of Rest In Minutes.

In the following section, these goals are represented over days of the week, months and grouped by work days (from Monday to Friday) and weekends (Saturday and Sunday).

  1- Goals observations

        1.a - variations by days of the week

Most of the global recommendations on physical activity for health are targeted toward meeting certain daily goals. Fig.3 below shows the daily achieved goals.

steps_days1 steps_days2

Fig. 3 : Daily goals

  • On average, the Fitbit user achieve between 8500 to nearly 12000 steps by day. According to Fitbit, the daily recommended steps for an adult are 10000 steps, which is equivalent to 30 min of daily exercise. Saturday is the most active day.
  • On average, the Fitbit user sleep between 5-6 hours and sleep the longest on Thursday. This is below the recommended by The Journal of the National Sleep Foundation. For an adult it is between 7-9 hours
  • The sleep efficiency seems constant around 85% and is also considered by The Journal of the National Sleep Foundation as a normal sleep cycle.
  • Calories burned are around 3000  which is more than the average person According to World Health Organisation, is between 1,600 and 2,000 calories per day.

            1.b- Goals parameters- variations by months

Although there are no global recommendations on physical activity for health, it is interesting to observe the evolution of goals parameters by month. We can see that October was the least active month, with few hours of sleep despite having the highest sleep efficiency. From Fig.4, we can also observe that the Fitbit user is more active during Spring and Summer months with higher hours of sleep but low sleep efficiency.

steps_months steps_months2

Fig. 4 : Monthly goals

            1.c- Goals parameters- variations by workdays or weekend

A new feature is created to group days by workdays (from Monday to Friday) and Weekends (Saturday and Sunday). Fig.5 shows the achieved goals parameters. During the workdays, the Fitbit users improve all the health goals comparing to weekends.

workdays_weekend1 workdays_weekend2

Fig. 5 : Workdays and Weekend goals

  2.Data interaction

In the following section, the relationship between several features in the dataset is observed. Along with the feature that distinguishes between workdays and weekends, other features are added to the datasets such as: Yesterday sleep hours and Yesterday's sleep efficiency in order to assess the effects of a previous night sleep on the goals. The following features: Days, Months and Weekdays have been encoded.

In this work, we consider Steps as our health and fitness goal that we wish to predict.

            2.a - Correlation

First, we look at the trend shared by predictors, i.e the features that will be used to predict Steps. We compute the correlation matrix shown in Fig.6.

correlation

Fig. 6 : Correlation matrix

From Fig.6, we can observe some strong correlation between some sleep predictors.  Distance is strongly correlated to Floors and both are inter-correlated to Minutes very active.

   3- Data analysis insights

  • In order to build our steps prediction model, we choose only to keep the variables Hours Sleep and Yesterday Sleep which respectively describe the sleep quality for the same day and day before.
  • Our data shows some strong correlation between predictors such as Distance and Minutes very active (0.76 correlation).  If two predictors are strongly correlated (correlation coefficient>0.76 ) we choose to keep only one in order to avoid redundant information in our data.

Fig.8 shows the relationship between Steps and other predictors. We can see that there is a strong linear relationship between Steps and the predictors. Distance according to Fitbit is calculated by multiplying your walking steps by your walking stride length.

Steps_distance_floors_calorie

Steps_date

Steps_activity

Fig. 8 : Relationship between Steps and predictors

II. Steps prediction and Evaluation

In order to predict the Steps, we split our data into train (75% of the dataset) and test (25% of the dataset). The train data has the following predictors:

  • Calories burned
  • Distance
  • Floors
  • Sedentary Minutes 
  • Lightly Active Minutes 
  • Fairly Active Minutes 
  • Very Active Minutes
  • Activity Calories
  • Work_or_Weekend
  • Hours Sleep
  • Yesterday Sleep
  • Months encoded

We fit different machine learning algorithms on our train dataset and make corresponding predictions on our test dataset. First we assess variable importance using linear regression and test p values for each predictor. Results are shown in Table.I

table

Table I : Feature importance and p-value

In order to measure models accuracy, we compute the RMSE and R2 as shown in Table.II.

edit

Table II : Prediction Scores for different Machine Learning

From Table II, simple linear regression seems to be well suited for the nature of this prediction problem as it has a lower value of RMSE in this case we have an error of 3437.32 steps. No improvement is observed using regularization such as Lasso or Ridge.

Fig.9 shows the comparison between Predicted Steps and Steps from the test dataset.

models

Fig. 9 : Comparison between models- Predicted Steps and Test Steps

III. Discussion

Considering the nature of our data, we have some multicollinearity and also a strong linear relationship between some features and our response variable Steps. Multicollinearity is important in regression analysis as it may cause unstable estimated coefficients and a loss of the model interpretability as it depends on the data used to train our model.

In order to have a constrained model, we introduce regularization of the linear regression using Ridge and Lasso methods to predict the Steps based predominantly on the most important features. Regularization, in this case, shrinks the least important coefficients (Ridge) or can eliminate them completely (Lasso) in order to improve generalization of the model. For this model, regularization doesn't improve interpretability or the predictive power of the model.

As for the Random Forest Regressor, it fails in predicting Steps especially for small values as observed in Fig.9. In the exploratory analysis, the mean daily Steps is between 8000 and 12000. The poor results of Random Forest Regressor are due to the nature of the algorithm being a nonlinear algorithm. In our case, our data is very linear and thus we need a lot of branches per tree to get a good approximation.

VI. Conclusion

In this work, the relationship between the measured Fitbit parameters was explored. We choose to predict the number of steps based on multiple features. Despite an apparent multicollinearity, simple linear regression seems to give better results predicting the number of steps.

 

About Author

Kawtar B

View all posts by Kawtar B >

Related Articles

Capstone
Catching Fraud in the Healthcare System
Capstone
The Convenience Factor: How Grocery Stores Impact Property Values
Capstone
Acquisition Due Dilligence Automation for Smaller Firms
Machine Learning
Pandemic Effects on the Ames Housing Market and Lifestyle
Machine Learning
The Ames Data Set: Sales Price Tackled With Diverse Models

Leave a Comment

Cancel reply

You must be logged in to post a comment.

Bruce Clark November 28, 2017
Magnificent beat ! I would like to apprentice while you amend your site, how could i subscribe for a weblog site? The account aided me a appropriate deal. I have been a little bit familiar of this your broadcast provided vibrant clear concept

View Posts by Categories

All Posts 2399 posts
AI 7 posts
AI Agent 2 posts
AI-based hotel recommendation 1 posts
AIForGood 1 posts
Alumni 60 posts
Animated Maps 1 posts
APIs 41 posts
Artificial Intelligence 2 posts
Artificial Intelligence 2 posts
AWS 13 posts
Banking 1 posts
Big Data 50 posts
Branch Analysis 1 posts
Capstone 206 posts
Career Education 7 posts
CLIP 1 posts
Community 72 posts
Congestion Zone 1 posts
Content Recommendation 1 posts
Cosine SImilarity 1 posts
Data Analysis 5 posts
Data Engineering 1 posts
Data Engineering 3 posts
Data Science 7 posts
Data Science News and Sharing 73 posts
Data Visualization 324 posts
Events 5 posts
Featured 37 posts
Function calling 1 posts
FutureTech 1 posts
Generative AI 5 posts
Hadoop 13 posts
Image Classification 1 posts
Innovation 2 posts
Kmeans Cluster 1 posts
LLM 6 posts
Machine Learning 364 posts
Marketing 1 posts
Meetup 144 posts
MLOPs 1 posts
Model Deployment 1 posts
Nagamas69 1 posts
NLP 1 posts
OpenAI 5 posts
OpenNYC Data 1 posts
pySpark 1 posts
Python 16 posts
Python 458 posts
Python data analysis 4 posts
Python Shiny 2 posts
R 404 posts
R Data Analysis 1 posts
R Shiny 560 posts
R Visualization 445 posts
RAG 1 posts
RoBERTa 1 posts
semantic rearch 2 posts
Spark 17 posts
SQL 1 posts
Streamlit 2 posts
Student Works 1687 posts
Tableau 12 posts
TensorFlow 3 posts
Traffic 1 posts
User Preference Modeling 1 posts
Vector database 2 posts
Web Scraping 483 posts
wukong138 1 posts

Our Recent Popular Posts

AI 4 AI: ChatGPT Unifies My Blog Posts
by Vinod Chugani
Dec 18, 2022
Meet Your Machine Learning Mentors: Kyle Gallatin
by Vivian Zhang
Nov 4, 2020
NICU Admissions and CCHD: Predicting Based on Data Analysis
by Paul Lee, Aron Berke, Bee Kim, Bettina Meier and Ira Villar
Jan 7, 2020

View Posts by Tags

#python #trainwithnycdsa 2019 2020 Revenue 3-points agriculture air quality airbnb airline alcohol Alex Baransky algorithm alumni Alumni Interview Alumni Reviews Alumni Spotlight alumni story Alumnus ames dataset ames housing dataset apartment rent API Application artist aws bank loans beautiful soup Best Bootcamp Best Data Science 2019 Best Data Science Bootcamp Best Data Science Bootcamp 2020 Best Ranked Big Data Book Launch Book-Signing bootcamp Bootcamp Alumni Bootcamp Prep boston safety Bundles cake recipe California Cancer Research capstone car price Career Career Day ChatGPT citibike classic cars classpass clustering Coding Course Demo Course Report covid 19 credit credit card crime frequency crops D3.js data data analysis Data Analyst data analytics data for tripadvisor reviews data science Data Science Academy Data Science Bootcamp Data science jobs Data Science Reviews Data Scientist Data Scientist Jobs data visualization database Deep Learning Demo Day Discount disney dplyr drug data e-commerce economy employee employee burnout employer networking environment feature engineering Finance Financial Data Science fitness studio Flask flight delay football gbm Get Hired ggplot2 googleVis H20 Hadoop hallmark holiday movie happiness healthcare frauds higgs boson Hiring hiring partner events Hiring Partners hotels housing housing data housing predictions housing price hy-vee Income industry Industry Experts Injuries Instructor Blog Instructor Interview insurance italki Job Job Placement Jobs Jon Krohn JP Morgan Chase Kaggle Kickstarter las vegas airport lasso regression Lead Data Scienctist Lead Data Scientist leaflet league linear regression Logistic Regression machine learning Maps market matplotlib Medical Research Meet the team meetup methal health miami beach movie music Napoli NBA netflix Networking neural network Neural networks New Courses NHL nlp NYC NYC Data Science nyc data science academy NYC Open Data nyc property NYCDSA NYCDSA Alumni Online Online Bootcamp Online Training Open Data painter pandas Part-time performance phoenix pollutants Portfolio Development precision measurement prediction Prework Programming public safety PwC python Python Data Analysis python machine learning python scrapy python web scraping python webscraping Python Workshop R R Data Analysis R language R Programming R Shiny r studio R Visualization R Workshop R-bloggers random forest Ranking recommendation recommendation system regression Remote remote data science bootcamp Scrapy scrapy visualization seaborn seafood type Selenium sentiment analysis sentiment classification Shiny Shiny Dashboard Spark Special Special Summer Sports statistics streaming Student Interview Student Showcase SVM Switchup Tableau teachers team team performance TensorFlow Testimonial tf-idf Top Data Science Bootcamp Top manufacturing companies Transfers tweets twitter videos visualization wallstreet wallstreetbets web scraping Weekend Course What to expect whiskey whiskeyadvocate wildfire word cloud word2vec XGBoost yelp youtube trending ZORI

NYC Data Science Academy

NYC Data Science Academy teaches data science, trains companies and their employees to better profit from data, excels at big data project consulting, and connects trained Data Scientists to our industry.

NYC Data Science Academy is licensed by New York State Education Department.

Get detailed curriculum information about our
amazing bootcamp!

Please enter a valid email address
Sign up completed. Thank you!

Offerings

  • HOME
  • DATA SCIENCE BOOTCAMP
  • ONLINE DATA SCIENCE BOOTCAMP
  • Professional Development Courses
  • CORPORATE OFFERINGS
  • HIRING PARTNERS
  • About

  • About Us
  • Alumni
  • Blog
  • FAQ
  • Contact Us
  • Refund Policy
  • Join Us
  • SOCIAL MEDIA

    © 2025 NYC Data Science Academy
    All rights reserved. | Site Map
    Privacy Policy | Terms of Service
    Bootcamp Application