Open navigation menu
Close suggestions
Search
Search
en
Change Language
Upload
Sign in
Sign in
Download free for days
0 ratings
0% found this document useful (0 votes)
110 views
11 pages
Body Fat Prediction
Body fat prediction.
Uploaded by
HEMANTH REDDY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Download
Save
Save Body Fat Prediction For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
0 ratings
0% found this document useful (0 votes)
110 views
11 pages
Body Fat Prediction
Body fat prediction.
Uploaded by
HEMANTH REDDY
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content,
claim it here
.
Available Formats
Download as PDF or read online on Scribd
Carousel Previous
Carousel Next
Download
Save
Save Body Fat Prediction For Later
Share
0%
0% found this document useful, undefined
0%
, undefined
Print
Embed
Report
Download
Save Body Fat Prediction For Later
You are on page 1
/ 11
Search
Fullscreen
aa 10% 12%) 16% image source: YouTube Mario Tomic (https://www.youtube.com/c/MarioTomicOfficial) Body Fat Level Predictions - Machine Learning vs. US Navy Formula instead of the criginal cateset, we are gonna use the data generated with my first notebook (https://www.kaggle.com/code/alexandrepetit881234/bodyfat-visualization) in adddition to the criginel cata, 2 few more column were created: BMI, 2 column with the individual Body Mass Index LeenPercent, the percent of lean tissues FatFreeMass, the lean mass in ko FFM, the fat-free mass index, Similar to BMI, but for the lean mass Overweight, BMI over 25 Obese, BMI over 30 HighFat, body-fat above 22 percentIn [1] import numpy as np # linear algebra import pandas as pd # data processing, CSV file 1/0 (e.g. pd.read_csv) import os for dirname, ., filenames in os.walk(' /kaggle/input') for filename in filenames: join(dirname, filename) ) import matplotlib.pyplot as plt import seaborn as sns ‘matplotlib inline /kaggle/input /body-fat-prediction-dataset /bodyfat .csv /kaggle/input /bodyfat-prediction-cleaned-extended/BodyFatCleaned.cs v 1.Data Preparation In [2] df = pd.read_csv(' /kaggle/input /bodyfat-prediction-cleaned-extended/BodyFatClean ed.csv') df.drop(‘Unnamed: 8°, axis df .head() , inplace=True) out [2] Density BocyFat Age Weight Height Neck Chest Abconen Hip Thigh 1 (1.0853 61 22 78.8 1.8 38.5 93.6 832.0 98.7 58.7 2 10414 25.3 22 70.0 1.7 34.0 95.8 87.9 99.2 58.6 3 1.0751 10.4 26 84.0 1.8 37.4 101.8 864 101.2 60.1 4 1.0340 28.7 24 82.8 1.8 34.4 97.3 100.0 101.8 63.2 es , 5 rows x 22 columnslet's add @ new column for people under 10% body-fat, it will be used to compare the density besec body-fat percent with the US navy formula fat percent df[‘LowFat'] = @ lf = 18 df[‘LowFat'][df['BodyFat'] < 1f] = 1 /opt/conda/1ib/python3 .7/site-packages/ipykernel_launcher.py:5: Set tingWithCopyWarning: A value is trying to be set on a copy of a slice from a DataFrame See the caveats in the documentation: https: //pandas.pydata.org/pan das-docs/stable/user_guide/indexing.html#returning-a-view-versus-a- copy This formula is used by the US navy to estimate the body-fat percent, let's see how it compare with the density based bocy-fat calculation %BF = 495 | ( 1.0324 - 0.18077 iagi0( waist - neck } + 0.15456 log‘0( height } ) - 450 In [4 df['NavyFat'] = 495 / (1.0324 - 6.19077 * np.logi@(df['Abdomen’] - df['Neck']) + @.15456 * np.logi@(df['Height’] * 190) - 450In [5] df['NavyFat'] = round(df['NavyFat'], 1) df.head() out[5] Density BoayFat Age Weight Heigrt Neck Chest Abcomen Hip Thigh © 1.0708 123 23 70.1 17 36.2 93.1 85.2 94.5 58.0 1 1.0853 6.1 22 78.8 1.8 385 93.6 83.0 98,7 58.7 wo 2 10414 25.3 22 70.0 1.7 34.0 95.8 87.9 98,2 58.6 we 3 1.0751 10.4 26 84.0 1.8 37.4 101.8 864 101.2 60.1 we 4 1.0340 28.7 24 83.8 1.8 34.4 97.3 100.0 101.8 63.2 we Po , 5 rows x 24 columns .use('ggplot') ts(1,3, figsize=(12, 4), sharey-True) sns.scatterplot(ax=ax[@], data=df, x='BodyFat', y='NavyFat', hue='LowFat') (ax=ax[1], date=df, BMI', y="BodyFat', hue='LowFat') (ax=ax[2], data=df, x='BMI', y='NavyFat', ‘LowFat' ) plt.ylabel('FatPercent') odyFat an ew!In [7] df[[‘BodyFat', ‘NavyFat', ‘Abdomen']][df['BodyFat'] < 10]out [7] BcdyFat 61 41 ma 78 37 78 37 a8 87 77 56 4.0 66 8.0 6.3 3.8 6.3 88 85 88 8.3 85 9.0 9.6 9.4 53 94 94 3.0 9g 86 66 6.0 96 7 75 5.2 NavyFat 14.1 14.0 13.0 178 137 105 114 176 16.3 158 145 88 18.1 16.6 14.1 118 12.8 18.5 18.7 121 16.8 15.0 178 21.3 WW? nS 13.8 185 16.1 148 14.0 10.7 19.2 168 18.1 14.2 18.3 Abcomen 83.0 82.5 83.6 90.9 79.7 748 73.9 835 84.5 76.0 79.5 70.4 778 82.0 79.8 778 78,4 82.8 82.9 788 86.0 83,1 88.8 916 74 765 778 812 819 79.4 83,7 78.0 89.1 83.9 79.4 815 82.8In [8 df[df['NavyFat'] < 18] out [a Dersity BooyFet_ Age Weight Height Neck Chest Abdomen Hip Thigh 47 1,0903 4.0 47° 580 17 340 834 70.4 87.2 506 150 1.0758 101 27 664 18 347 885 728 911 536 4 > with the navy body fat formule, only two people have an estimated bofy fat level under 10%. Much less than the people under 10% body-fat calculated with the density 2. Machine Learning Model we will use the measurements of the different bocy pert to estimate the body-fat percent of en individual, Because the density is used to calculate the BodyFat column, we will not keep it with the training date In [9 df.columns Out [9. Index(['Density', ‘BodyFat’, ‘Age’, ‘Weight’, ‘Height’, ‘Neck", ‘Ch est’, "Abdomen', ‘Hip’, ‘Thigh’, ‘Knee’, ‘Ankle’, ‘Biceps’, ‘Forea rm ‘Wrist’, ‘BMI’, ‘LeanPercent', ‘FatFreeMass’, ‘FFMI', ‘Overw eight’, “Obese”, ‘HighFat', ‘LowFat’, ‘NavyFat'], dtype=' object’) Data Selection and SeparationIn [10] x df[['Age', ‘Weight’, ‘Height’, ‘Neck’, ‘Chest’ ‘abdomen’, ‘Hip’, ‘Thigh’, ‘Knee’, ‘Ankle’, ‘Biceps’, ‘Forearm’ ‘Wrist’ ]]) y-b = df[‘BodyFat’] y_n = df[‘NavyFat’] In [11] from sklearn.model_selection import train_test_split X_train, X test, y-train_b, y_test_b, y_train_n, y_test_n = train_test_split(x, y-b, yn, test_ size=0.25, rando m_state=42) In [12] int(X_train. print (y_train_t (186, 13) (62, 13) (186,) (62,) (186,) (62,) For regression problem, we cannot use the accuracy score. We are going to use the mean squared error In [13] from sklearn.metrics import mean_squared_error from time import perf_counter Linear RegressionIn [14 from sklearn.linear_model import LinearRegression start = perf_counter() reg = LinearRegression( ) reg.fit(X_train, y_train_t) y-pred_b = reg.p’ (X_test) reg_mse_b = mean_squared_error(y_test_b, y_pred_b) print(f'the mean squared error for linear regression on density body-fat is {rou nd(reg_mse_t, 2) }") reg.fit(X_train, y_train_n) y-pred_n = reg.predict(X_test) reg_mse_n = mean_squared_error(y_test_n, y_pred_n) print(f'the mean squared error for linear regression on navy body-fat is {round( reg_mse_n, 2)}") end = perf_counter() elapsed_time = round(end - start, 3) print(f'it took {elapsed_time} second for predicting the body fat percent using linear regression’) the mean squared error for linear regression on density body-fat is 19.45 the mean squared error for linear regression on navy body-fat is @ 15 it took @.029 second for predicting the body fat percent using line ar regression Decision TreeIn [15] from sklearn.tree import DecisionTreeRegressor start = perf_counter() dtr = DecisionTreeRegressor() dtr.fit(X_trair, y_train_b) y-pred_b = dtr.p’ (X_test) tree_mse_b = mean_squared_error(y_test_b, y_pred_b) print(f'the mean squared error for decision tree on density body-fat is {round(t ree_mse_b, 2) }') dtr.fit(X_trair, y_train_b) y-pred_n = dtr.predict(X_test) tree_mse_n = mean_squared_error(y_test_n, y_pred_n) print(f'the mean squared error for decision tree on navy body-fat is {round(tree _mse_n, 2)}") end = perf_counter() elapsed_time = round(end - start, 3) print(f'it took {elapsed_time} second to predict the body fat percent using a de cision tree’) ‘the mean squared error for decision tree on density body-fat is 40. A2 the mean squared error for decision tree on navy body-fat is 33.97 it took 6.814 second to predict the body fat percent using a decisi on tree Lineer regression gives us presictions closer to the velue we celculete before for both the density based body-fat anc the navy formula based body-fat. Decision Tree also took a little more time. For some problems, we don't need a complex modelIn [16 mean_squared_error(y_b, y_n) nse_navy_fat mse_navy_fat = round(mse_navy_fat, 2) print(f'The mean squared error for the Navy bod-fat formula is {mse_navy_fat}’) The mean squared error for the Navy bod-fat formula is 27.4 Wait, was machine learning necessary for predicting the body-fat? we saw just before that the navy body-fat formula was giving us a gcod estimation of the body-fat level. The mean squared error for the formule is even smaller than the mean squared error of the cecision tree
You might also like
Body Fat..
PDF
No ratings yet
Body Fat..
2 pages
Sulmet Kibernetike Të Shtetit Të Iranit Kundër Qeverisë Shqiptare
PDF
No ratings yet
Sulmet Kibernetike Të Shtetit Të Iranit Kundër Qeverisë Shqiptare
19 pages
TC7 - CH4
PDF
No ratings yet
TC7 - CH4
110 pages
Samudera Logistics Brief October 2022 PDF
PDF
No ratings yet
Samudera Logistics Brief October 2022 PDF
17 pages
Soluciones Unidad 3 Opcionales
PDF
No ratings yet
Soluciones Unidad 3 Opcionales
15 pages
Research Methodology - Group Assignment - Group 6
PDF
No ratings yet
Research Methodology - Group Assignment - Group 6
36 pages
Micel
PDF
No ratings yet
Micel
15 pages
As Level Biology Summary Notes (2022-2024 Syllabus)
PDF
100% (1)
As Level Biology Summary Notes (2022-2024 Syllabus)
5 pages
Concept of Drug Delivery System
PDF
No ratings yet
Concept of Drug Delivery System
60 pages
A Critical Review On Graphitic Carbon Nitride (g-C3N4) - Based Composites For Environmental Remediation-Inglês
PDF
No ratings yet
A Critical Review On Graphitic Carbon Nitride (g-C3N4) - Based Composites For Environmental Remediation-Inglês
44 pages
Cc2lab Sodium Potassium Quiz WT Rev
PDF
No ratings yet
Cc2lab Sodium Potassium Quiz WT Rev
13 pages
Ing Gris
PDF
No ratings yet
Ing Gris
9 pages
The Arup Journal Issue 3 2007
PDF
No ratings yet
The Arup Journal Issue 3 2007
68 pages
HERG and The Heart
PDF
No ratings yet
HERG and The Heart
3 pages
Karappan: National Institute of Siddha
PDF
No ratings yet
Karappan: National Institute of Siddha
98 pages
RZB12-6-3 Remote Zone Interface Installation Sheet
PDF
No ratings yet
RZB12-6-3 Remote Zone Interface Installation Sheet
8 pages
Soal Semster Bahasa Inggris IX TKJ
PDF
No ratings yet
Soal Semster Bahasa Inggris IX TKJ
4 pages
CHAPTER 2 The IS LM Model
PDF
No ratings yet
CHAPTER 2 The IS LM Model
73 pages
Kaur 2020
PDF
No ratings yet
Kaur 2020
7 pages
Chaitanya Ki Chahal Pahal PDF
PDF
No ratings yet
Chaitanya Ki Chahal Pahal PDF
34 pages
Ros New 1
PDF
No ratings yet
Ros New 1
49 pages
DCT Brochure 03172021
PDF
No ratings yet
DCT Brochure 03172021
2 pages
Firdous Histology 2ndyear
PDF
No ratings yet
Firdous Histology 2ndyear
52 pages
Pathophysiology, Diagnosis, and Management of Dyslipidemia: Gerald T. Gau, MD, and R. Scott Wright, MD, FACC, FAHA, FESC
PDF
No ratings yet
Pathophysiology, Diagnosis, and Management of Dyslipidemia: Gerald T. Gau, MD, and R. Scott Wright, MD, FACC, FAHA, FESC
42 pages
Neutrosophic Hypersoft Matrices With Application To Solve Multiattributive Decision-Making Problems
PDF
No ratings yet
Neutrosophic Hypersoft Matrices With Application To Solve Multiattributive Decision-Making Problems
17 pages
CHAPTER 1.5 Conic in Polar
PDF
No ratings yet
CHAPTER 1.5 Conic in Polar
5 pages
Scenario: Respiratory Disorders
PDF
No ratings yet
Scenario: Respiratory Disorders
4 pages
ديسكفر - 1 ابتدائي - ترم 1 - مذكرة 4 - 2
PDF
No ratings yet
ديسكفر - 1 ابتدائي - ترم 1 - مذكرة 4 - 2
37 pages
USP A Sip
PDF
No ratings yet
USP A Sip
26 pages
Formulae Book Cs New 1 51
PDF
No ratings yet
Formulae Book Cs New 1 51
53 pages
Especificaciones Técnicas Maquina de Anestesia Wato Ex-30
PDF
No ratings yet
Especificaciones Técnicas Maquina de Anestesia Wato Ex-30
2 pages
ملزمة الاسلامية 2024 الاستاذ عدنان البياتي - السادس العلمي - موقع سطور
PDF
No ratings yet
ملزمة الاسلامية 2024 الاستاذ عدنان البياتي - السادس العلمي - موقع سطور
127 pages
14.10.2022 - Leo Brochure - Vertical Low Res
PDF
No ratings yet
14.10.2022 - Leo Brochure - Vertical Low Res
9 pages
Decorate
PDF
No ratings yet
Decorate
40 pages
X++ Control Statements
PDF
No ratings yet
X++ Control Statements
42 pages
Cambridge IGCSE: Physics 0625/22
PDF
No ratings yet
Cambridge IGCSE: Physics 0625/22
20 pages
Western Blotting Teaching Kit Manual
PDF
No ratings yet
Western Blotting Teaching Kit Manual
10 pages
Tales From The Aerosphere v1.00
PDF
No ratings yet
Tales From The Aerosphere v1.00
96 pages
Approved New Bank Structure As of 31 Oct 2022 en 1 Rev
PDF
No ratings yet
Approved New Bank Structure As of 31 Oct 2022 en 1 Rev
12 pages
PM 2000XL Pro
PDF
No ratings yet
PM 2000XL Pro
6 pages
Panasonc DC-TZ90 - BASIC-Operating - Instructions - User - Manual
PDF
No ratings yet
Panasonc DC-TZ90 - BASIC-Operating - Instructions - User - Manual
64 pages
Root Resorption in Maxillary & Mandiblar Anterior Segment During Active Orthodontic Treatment - A CBCT Study
PDF
No ratings yet
Root Resorption in Maxillary & Mandiblar Anterior Segment During Active Orthodontic Treatment - A CBCT Study
18 pages
Gaussian Tips
PDF
No ratings yet
Gaussian Tips
70 pages
0894 - Advanced Materials - 2022 - Saadi - Direct Ink Writing A 3d Printing Technology For Diverse Materials
PDF
No ratings yet
0894 - Advanced Materials - 2022 - Saadi - Direct Ink Writing A 3d Printing Technology For Diverse Materials
57 pages
Inventory Management
PDF
No ratings yet
Inventory Management
22 pages
(1-14) Study On Individual's Preference About Online Cab Booking Services
PDF
No ratings yet
(1-14) Study On Individual's Preference About Online Cab Booking Services
14 pages
Data Sheet: BTA204S Series D, E and F BTA204M Series D, E and F
PDF
No ratings yet
Data Sheet: BTA204S Series D, E and F BTA204M Series D, E and F
8 pages
PR Derbi Senda Eng
PDF
No ratings yet
PR Derbi Senda Eng
4 pages
拼音练习题
PDF
No ratings yet
拼音练习题
49 pages
In Fine On Heat Pump Web in Ar 1657122562261
PDF
No ratings yet
In Fine On Heat Pump Web in Ar 1657122562261
31 pages
Next Gen CAR
PDF
No ratings yet
Next Gen CAR
11 pages
Larsen & Toubro Limited: Modular Fabrication Facility, Hazira
PDF
No ratings yet
Larsen & Toubro Limited: Modular Fabrication Facility, Hazira
1 page
Sports Authority of India: Col. Raj Singh Bishnoi Sr. Executive Director (Academics) Prof. Kalpana Sharma Director, NS NIS
PDF
No ratings yet
Sports Authority of India: Col. Raj Singh Bishnoi Sr. Executive Director (Academics) Prof. Kalpana Sharma Director, NS NIS
4 pages
Truong Quoc Khang Operational BM5723
PDF
No ratings yet
Truong Quoc Khang Operational BM5723
11 pages
Noakes 1990
PDF
No ratings yet
Noakes 1990
12 pages
Practice Test
PDF
No ratings yet
Practice Test
4 pages
DRDO CEPTAM 10 AA Notifictaion
PDF
No ratings yet
DRDO CEPTAM 10 AA Notifictaion
5 pages
Automatic Arabic Number Plate Recognition
PDF
No ratings yet
Automatic Arabic Number Plate Recognition
7 pages
Bec & BMS
PDF
No ratings yet
Bec & BMS
8 pages
CVFDdiffusion 2 D
PDF
No ratings yet
CVFDdiffusion 2 D
17 pages
A735d538 Lab-5
PDF
No ratings yet
A735d538 Lab-5
9 pages
Lab-6 n824g389 Bsan
PDF
No ratings yet
Lab-6 n824g389 Bsan
6 pages
Python Project
PDF
No ratings yet
Python Project
3 pages
Airflow Codespace Syntax
PDF
No ratings yet
Airflow Codespace Syntax
2 pages