Calories Burned Prediction with Python

Machine Learning Project on Calories burned prediction with Python.

We all know that the amount of calories we burn is all dependent on the number of physical movements and exercises we do. In this article, I will take you through a very simple Machine Learning task on Calories Burned Prediction with Python programming language.

Calories Burned Prediction with Python

I will start this machine learning project on the task of calories burned prediction with Python by importing the libraries and datasets that we need:

Also, Read – 100+ Machine Learning Projects Solved and Explained.

Now let’s read the datasets and merge them for further analysis:

indexUser_IDGenderAgeHeightWeightDurationHeart_RateBody_TempCaloriesIntercept
0014733363male68190.094.029.0105.040.8231.01
1114861698female20166.060.014.094.040.366.01
2211179863male69179.079.05.088.038.726.01
3316180408female34179.071.013.0100.040.571.01
4417771927female27154.058.010.081.039.835.01

Now let’s visualize the dataset to see what we are going to work with in terms of Calories burned vs Duration of Exercise:

calories burned

Now we need to create the features and a response:

X = df.loc[:, ['Intercept', 'Duration']]
y = df.loc[:, 'Calories']

Now, I will implement a linear regression algorithm without using any library to demonstrate how we can prepare our own machine learning algorithm:

Intercept calculated by hand: -21.82810252605084
Slope calculated by hand:  7.169783349587853
calories burned vs duration of excercise
print('Exercising for 15.5 minutes will burn an estimated {:.2f} calories.'.format(
    by_hand_coefs[0] + by_hand_coefs[1] * 15.5))
Exercising for 15.5 minutes will burn an estimated 89.30 calories.

Now to verify that we have created a good algorithm let’s use the linear regression model provided by Scikit-Learn:

Intercept from library: -21.82810252605087 
Slope from library: 7.169783349587856

As you can see our prediction of algorithm created by me is very similar to the prediction of linear regression model provided by Scikit-Learn library in Python.

I hope you liked this article on a very simple Machine Learning project on calories burned prediction with Python programming language. Feel free to ask your valuable questions in the comments section below.

Default image
Aman Kharwal

I am a programmer from India, and I am here to guide you with Data Science, Machine Learning, Python, and C++ for free. I hope you will learn a lot in your journey towards Coding, Machine Learning and Artificial Intelligence with me.

8 Comments

  1. Great comparison excercise, using theorical regresion and sci.kit.learn library, thanks Aman

  2. Really a great work Aman. Thanks for sharing with the public.

  3. i am not able to download the dataset, please can you help me out to get the dataset

  4. Aman thanks for the simple and clear understanging of LR concepts.

Leave a Reply

Do NOT follow this link or you will be banned from the site!