<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by victor babatunde on Medium]]></title>
        <description><![CDATA[Stories by victor babatunde on Medium]]></description>
        <link>https://medium.com/@victordamilola42?source=rss-97b2a601bb82------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*RAZkRmzHV8d7C614</url>
            <title>Stories by victor babatunde on Medium</title>
            <link>https://medium.com/@victordamilola42?source=rss-97b2a601bb82------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 01:36:56 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@victordamilola42/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Calories Dataset, Modification and Machine Learning]]></title>
            <link>https://medium.com/@victordamilola42/calories-dataset-modification-and-machine-learning-a9281e61f37d?source=rss-97b2a601bb82------2</link>
            <guid isPermaLink="false">https://medium.com/p/a9281e61f37d</guid>
            <dc:creator><![CDATA[victor babatunde]]></dc:creator>
            <pubDate>Wed, 31 Jan 2024 11:11:27 GMT</pubDate>
            <atom:updated>2024-01-31T11:11:27.648Z</atom:updated>
            <content:encoded><![CDATA[<p>I found this <a href="https://medium.com/kaggle/input/bellabeat-case-study-fitbit-data/Fitabase%20Data%204.12.16%E2%80%935.12.16/dailyActivity_merged.csv">dataset</a> with 15 columns and about a thousand rows on kaggle :</p><p><a href="https://www.kaggle.com/code/victorbabatunde/notebookbf24933938">Full work here</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R5yK_u-UYJZa7-CuL2ffcA.png" /></figure><p>Having imported the necessary libraries and read the file, I checked to see if there were missing values: (beat.isna()).sum() .</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/896/1*tDhrMI7OLXuoM2r6B6Ssjg.png" /></figure><p>It was reflected with the aid of a scatterplot that there is a relationship between the TotalDistance and Calories as expected. The calories increase as the distance increases on the plot.</p><h3><strong>Collapsing Columns</strong></h3><p>There are columns with distance and time which could be combined and still reflected in Speed.</p><p>Speed = Distance/Time</p><pre>activetimehr=(beat[&#39;VeryActiveMinutes&#39;])/60<br>beat[&#39;speed active(km/hr)&#39;]=beat[&#39;VeryActiveDistance&#39;]/activetimehr<br>moderatetimehr=(beat[&#39;FairlyActiveMinutes&#39;])/60<br>beat[&#39;speed moderate(km/hr)&#39;]=beat[&#39;ModeratelyActiveDistance&#39;]/moderatetimehr<br>lighttimehr=(beat[&#39;LightlyActiveMinutes&#39;])/60<br>beat[&#39;speed light(km/hr)&#39;]=beat[&#39;LightActiveDistance&#39;]/lighttimehr<br>Sedentarytimehr=(beat[&#39;SedentaryMinutes&#39;])/60<br>beat[&#39;speed sedentary(km/hr)&#39;]=beat[&#39;SedentaryActiveDistance&#39;]/Sedentarytimehr</pre><pre>#dropping TrackerDistance since it&#39;s the same as TotalDistance.<br># dropping id since we have index nu<br>#dropping LoggedActivitiesDistance because it doesn&#39;t reflect any data<br>#dropping VeryActiveDistance ModeratelyActiveDistance LightActiveDistance SedentaryActiveDistance FairlyActiveMinutes<br>#LightlyActiveMinute SedentaryMinutes since speed already reflects all these <br><br>beat=beat.drop(columns=[&#39;VeryActiveDistance&#39;, &#39;ModeratelyActiveDistance&#39;, &#39;LightActiveDistance&#39;, &#39;SedentaryActiveDistance&#39;, &#39;FairlyActiveMinutes&#39;,&#39;LoggedActivitiesDistance&#39;,&#39;VeryActiveMinutes&#39;,&#39;LightlyActiveMinutes&#39;, &#39;SedentaryMinutes&#39;,&#39;Id&#39;,&#39;TrackerDistance&#39;])</pre><p>Also, the calories burnt per step could be calculated :</p><pre>beat[&#39;calories per step&#39;]=beat[&#39;Calories&#39;]/beat[&#39;TotalSteps&#39;]</pre><h3><strong>Encoding and Scaling</strong></h3><pre>#importing scaling tool<br>from sklearn.preprocessing import StandardScaler<br>scaler=StandardScaler()<br></pre><pre>#scaling and transforming the dataset<br>scaled_data=scaler.fit_transform(beat)</pre><pre>X=scaled_df<br>y=beat[&#39;Calories&#39;]</pre><pre>Inserting scaled data into column<br>scaled_df = pd.DataFrame(scaled_data, columns=beat.columns)</pre><pre>#Splitting Scaled data<br>#dropping calories since it&#39;s the target feature since it belongs to the y axis<br>scaled_df=scaled_df.drop(columns=&#39;Calories&#39;)</pre><pre>#importing knn regressor from sklearn<br>from sklearn.neighbors import KNeighborsRegressor<br>knnr = KNeighborsRegressor(n_neighbors=3)</pre><pre>#fitting dataset<br>knnr.fit(X_train, y_train)</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1eVOYr3gGPrp526wR9X-oA.png" /></figure><p>The above shows the knnr score, and prediction for expected calories based on the given data on the x axis.</p><p>Also, a random test for some rows and we see how close the values are :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*CvOXDWCAR5zxn9pkML1R3g.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a9281e61f37d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>