{"id":8178,"date":"2025-10-29T13:51:33","date_gmt":"2025-10-29T13:51:33","guid":{"rendered":"https:\/\/techtrendfeed.com\/?p=8178"},"modified":"2025-10-29T13:51:33","modified_gmt":"2025-10-29T13:51:33","slug":"utilizing-numpy-to-analyze-my-each-day-habits-sleep-display-screen-time-temper","status":"publish","type":"post","link":"https:\/\/techtrendfeed.com\/?p=8178","title":{"rendered":"Utilizing NumPy to Analyze My Each day Habits (Sleep, Display screen Time &#038;\u00a0Temper)"},"content":{"rendered":"<p> <br \/>\n<\/p>\n<div>\n<p class=\"wp-block-paragraph\"> a small NumPy challenge collection the place I attempt to really <em>construct one thing<\/em> with NumPy as an alternative of simply going by means of random capabilities and documentation. I\u2019ve all the time felt that the easiest way to be taught is by doing, so on this challenge, I wished to create one thing each sensible and private.<\/p>\n<p class=\"wp-block-paragraph\">The thought was easy: analyze my each day habits\u200a\u2014\u200asleep, examine hours, display screen time, train, and temper\u200a\u2014\u200aand see how they have an effect on my productiveness and basic well-being. The info isn\u2019t actual; it\u2019s fictional, simulated over 30 days. However the objective isn\u2019t the accuracy of the information\u200a\u2014\u200ait\u2019s studying methods to use NumPy meaningfully.<\/p>\n<p class=\"wp-block-paragraph\">So let\u2019s stroll by means of the method step-by-step.<\/p>\n<h2 class=\"wp-block-heading\">Step 1\u200a\u2014\u200aLoading and Understanding the\u00a0Knowledge<\/h2>\n<p class=\"wp-block-paragraph\">I began by making a easy NumPy array that contained 30 rows (one for every day) and 6 columns\u200a\u2014\u200aevery column representing a unique behavior metric. Then I saved it as a\u00a0<code>.npy<\/code> file so I may simply load it later.<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># TODO: Import NumPy and cargo the .npy knowledge file\nimport numpy as np\nknowledge = np.load(\u2018activity_data.npy\u2019)<\/code><\/pre>\n<p class=\"wp-block-paragraph\">As soon as loaded, I wished to substantiate that all the things seemed as anticipated. So I checked the <strong>form<\/strong> (to know what number of rows and columns there have been) and the <strong>variety of dimensions<\/strong> (to substantiate it\u2019s a 2D desk, not a 1D record).<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># TODO: Print array form, first few rows, and so forth.\nknowledge.form\nknowledge.ndim<\/code><\/pre>\n<p class=\"wp-block-paragraph\"><strong>OUTPUT: 30 rows, 6 columns, and ndim=2<\/strong><\/p>\n<p class=\"wp-block-paragraph\">I additionally printed out the primary few rows simply to visually verify that every worth seemed tremendous\u200a\u2014\u200aas an illustration, that sleep hours weren\u2019t adverse or that the temper values have been inside an affordable vary.<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># TODO: High 5 rows\nknowledge[:5]<\/code><\/pre>\n<p class=\"wp-block-paragraph\"><strong>Output:<\/strong><\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-markup\">array([[ 1. , 6.5, 5. , 4.2, 20. , 6. ],\n[ 2. , 7.2, 6. , 3.1, 35. , 7. ],\n[ 3. , 5.8, 4. , 5.5, 0. , 5. ],\n[ 4. , 8. , 7. , 2.5, 30. , 8. ],\n[ 5. , 6. , 5. , 4.8, 10. , 6. ]])<\/code><\/pre>\n<h2 class=\"wp-block-heading\">Step 2\u200a\u2014\u200aValidating the\u00a0Knowledge<\/h2>\n<p class=\"wp-block-paragraph\">Earlier than doing any evaluation, I wished to verify the information made sense. It\u2019s one thing we regularly skip when working with fictional knowledge, but it surely\u2019s nonetheless good follow.<\/p>\n<p class=\"wp-block-paragraph\">So I checked:<\/p>\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">No adverse sleep hours<\/li>\n<li class=\"wp-block-list-item\">No temper scores lower than 1 or higher than 10<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\">For sleep, that meant choosing the sleep column (index 1 in my array) and checking if any values have been beneath zero.<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># Make sure that values are affordable (no adverse sleep)\nknowledge[:, 1] &lt; 0<\/code><\/pre>\n<p class=\"wp-block-paragraph\"><strong>Output:<\/strong><\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-markup\">array([False, False, False, False, False, False, False, False, False,\nFalse, False, False, False, False, False, False, False, False,\nFalse, False, False, False, False, False, False, False, False,\nFalse, False, False])<\/code><\/pre>\n<p class=\"wp-block-paragraph\">This implies no negatives. Then I did the identical for temper. I counted to search out that the temper column was at index 5, and checked if any have been beneath 1 or above 10.<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># Is temper out of vary?\nknowledge[:, 5] &lt; 1\nknowledge[:, 5] &gt; 10<\/code><\/pre>\n<p class=\"wp-block-paragraph\"><strong>We received the identical output.<\/strong><\/p>\n<p class=\"wp-block-paragraph\">Every thing seemed good, so we may transfer on.<\/p>\n<h2 class=\"wp-block-heading\">Step 3\u200a\u2014\u200aSplitting the Knowledge into\u00a0Weeks<\/h2>\n<p class=\"wp-block-paragraph\">I had 30 days of information, and I wished to research it week by week. The primary intuition was to make use of NumPy\u2019s <code>cut up()<\/code> perform, however that failed as a result of 30 isn\u2019t evenly divisible by 4. So as an alternative, I used <code>np.array_split()<\/code>, which permits uneven splits.<\/p>\n<p class=\"wp-block-paragraph\">That gave me:<\/p>\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">Week 1 \u2192 8 days<\/li>\n<li class=\"wp-block-list-item\">Week 2 \u2192 8 days<\/li>\n<li class=\"wp-block-list-item\">Week 3 \u2192 7 days<\/li>\n<li class=\"wp-block-list-item\">Week 4 \u2192 7 days<\/li>\n<\/ul>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># TODO: Slice knowledge into week 1, week 2, week 3, week 4\nweekly_data = np.array_split(knowledge, 4)\nweekly_data<\/code><\/pre>\n<p class=\"wp-block-paragraph\"><strong>Output:<\/strong><\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-markup\">[array([[ 1. , 6.5, 5. , 4.2, 20. , 6. ],\n[ 2. , 7.2, 6. , 3.1, 35. , 7. ],\n[ 3. , 5.8, 4. , 5.5, 0. , 5. ],\n[ 4. , 8. , 7. , 2.5, 30. , 8. ],\n[ 5. , 6. , 5. , 4.8, 10. , 6. ],\n[ 6. , 7.5, 6. , 3.3, 25. , 7. ],\n[ 7. , 8.2, 3. , 6.1, 40. , 7. ],\n[ 8. , 6.3, 4. , 5. , 15. , 6. ]]),\n\narray([[ 9. , 7. , 6. , 3.2, 30. , 7. ],\n[10. , 5.5, 3. , 6.8, 0. , 5. ],\n[11. , 7.8, 7. , 2.9, 25. , 8. ],\n[12. , 6.1, 5. , 4.5, 15. , 6. ],\n[13. , 7.4, 6. , 3.7, 30. , 7. ],\n[14. , 8.1, 2. , 6.5, 50. , 7. ],\n[15. , 6.6, 5. , 4.1, 20. , 6. ],\n[16. , 7.3, 6. , 3.4, 35. , 7. ]]),\n\narray([[17. , 5.9, 4. , 5.6, 5. , 5. ],\n[18. , 8.3, 7. , 2.6, 30. , 8. ],\n[19. , 6.2, 5. , 4.3, 10. , 6. ],\n[20. , 7.6, 6. , 3.1, 25. , 7. ],\n[21. , 8.4, 3. , 6.3, 40. , 7. ],\n[22. , 6.4, 4. , 5.1, 15. , 6. ],\n[23. , 7.1, 6. , 3.3, 30. , 7. ]]),\n\narray([[24. , 5.7, 3. , 6.7, 0. , 5. ],\n[25. , 7.9, 7. , 2.8, 25. , 8. ],\n[26. , 6.2, 5. , 4.4, 15. , 6. ],\n[27. , 7.5, 6. , 3.5, 30. , 7. ],\n[28. , 8. , 2. , 6.4, 50. , 7. ],\n[29. , 6.5, 5. , 4.2, 20. , 6. ],\n[30. , 7.4, 6. , 3.6, 35. , 7. ]])]<\/code><\/pre>\n<p class=\"wp-block-paragraph\">Now the information was in 4 chunks, and I may simply analyze each individually.<\/p>\n<h2 class=\"wp-block-heading\">Step 4\u200a\u2014\u200aCalculating Weekly\u00a0Metrics<\/h2>\n<p class=\"wp-block-paragraph\">I wished to get a way of how every behavior modified from week to week. So I targeted on 4 most important issues:<\/p>\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">Common sleep<\/li>\n<li class=\"wp-block-list-item\">Common examine hours<\/li>\n<li class=\"wp-block-list-item\">Common display screen time<\/li>\n<li class=\"wp-block-list-item\">Common temper rating<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\">I saved every week\u2019s array in a separate variable, then used <code>np.imply()<\/code> to calculate the averages for every metric.<\/p>\n<h3 class=\"wp-block-heading\">Common sleep\u00a0hours<\/h3>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># retailer into variables\nweek_1 = weekly_data[0]\nweek_2 = weekly_data[1]\nweek_3 = weekly_data[2]\nweek_4 = weekly_data[3]\n\n# TODO: Compute common sleep\nweek1_avg_sleep = np.imply(week_1[:, 1])\nweek2_avg_sleep = np.imply(week_2[:, 1])\nweek3_avg_sleep = np.imply(week_3[:, 1])\nweek4_avg_sleep = np.imply(week_4[:, 1])<\/code><\/pre>\n<h3 class=\"wp-block-heading\">Common examine\u00a0hours<\/h3>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># TODO: Compute common examine hours\nweek1_avg_study = np.imply(week_1[:, 2])\nweek2_avg_study = np.imply(week_2[:, 2])\nweek3_avg_study = np.imply(week_3[:, 2])\nweek4_avg_study = np.imply(week_4[:, 2])<\/code><\/pre>\n<h3 class=\"wp-block-heading\">Common display screen\u00a0time<\/h3>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># TODO: Compute common display screen time\nweek1_avg_screen = np.imply(week_1[:, 3])\nweek2_avg_screen = np.imply(week_2[:, 3])\nweek3_avg_screen = np.imply(week_3[:, 3])\nweek4_avg_screen = np.imply(week_4[:, 3])<\/code><\/pre>\n<h3 class=\"wp-block-heading\">Common temper\u00a0rating<\/h3>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># TODO: Compute common temper rating\nweek1_avg_mood = np.imply(week_1[:, 5])\nweek2_avg_mood = np.imply(week_2[:, 5])\nweek3_avg_mood = np.imply(week_3[:, 5])\nweek4_avg_mood = np.imply(week_4[:, 5])<\/code><\/pre>\n<p class=\"wp-block-paragraph\">Then, to make all the things simpler to learn, I formatted the outcomes properly.<\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-python\"># TODO: Show weekly outcomes clearly\nprint(f\u201dWeek 1 \u2014 Common sleep: {week1_avg_sleep:.2f} hrs, Research: {week1_avg_study:.2f} hrs, \u201c\nf\u201dDisplay screen time: {week1_avg_screen:.2f} hrs, Temper rating: {week1_avg_mood:.2f}\u201d)\n\nprint(f\u201dWeek 2 \u2014 Common sleep: {week2_avg_sleep:.2f} hrs, Research: {week2_avg_study:.2f} hrs, \u201c\nf\u201dDisplay screen time: {week2_avg_screen:.2f} hrs, Temper rating: {week2_avg_mood:.2f}\u201d)\n\nprint(f\u201dWeek 3 \u2014 Common sleep: {week3_avg_sleep:.2f} hrs, Research: {week3_avg_study:.2f} hrs, \u201c\nf\u201dDisplay screen time: {week3_avg_screen:.2f} hrs, Temper rating: {week3_avg_mood:.2f}\u201d)\n\nprint(f\u201dWeek 4 \u2014 Common sleep: {week4_avg_sleep:.2f} hrs, Research: {week4_avg_study:.2f} hrs, \u201c\nf\u201dDisplay screen time: {week4_avg_screen:.2f} hrs, Temper rating: {week4_avg_mood:.2f}\u201d)<\/code><\/pre>\n<p class=\"wp-block-paragraph\"><strong>Output:<\/strong><\/p>\n<pre class=\"wp-block-prismatic-blocks\"><code class=\"language-markup\">Week 1 \u2013 Common sleep: 6.94 hrs, Research: 5.00 hrs, Display screen time: 4.31 hrs, Temper rating: 6.50\nWeek 2 \u2013 Common sleep: 6.97 hrs, Research: 5.00 hrs, Display screen time: 4.39 hrs, Temper rating: 6.62\nWeek 3 \u2013 Common sleep: 7.13 hrs, Research: 5.00 hrs, Display screen time: 4.33 hrs, Temper rating: 6.57\nWeek 4 \u2013 Common sleep: 7.03 hrs, Research: 4.86 hrs, Display screen time: 4.51 hrs, Temper rating: 6.57<\/code><\/pre>\n<h2 class=\"wp-block-heading\">Step 5\u200a\u2014\u200aMaking Sense of the\u00a0Outcomes<\/h2>\n<p class=\"wp-block-paragraph\">As soon as I printed out the numbers, some patterns began to indicate up.<\/p>\n<p class=\"wp-block-paragraph\">My <strong>sleep hours<\/strong> have been fairly regular for the primary two weeks (round 6.9 hours), however in week three, they jumped to round 7.1 hours. Which means I used to be \u201csleeping higher\u201d because the month went on. By week 4, it stayed roughly round 7.0 hours.<\/p>\n<p class=\"wp-block-paragraph\">For <strong>examine hours<\/strong>, it was the alternative. Week one and two had a mean of round 5 hours per day, however by week 4, it had dropped to about 4 hours. Mainly, I began off sturdy however slowly misplaced momentum\u200a\u2014\u200awhich, truthfully, sounds about proper.<\/p>\n<p class=\"wp-block-paragraph\">Then got here <strong>display screen time<\/strong>. This one damage a bit. In week one, it was roughly 4.3 hours per day, and it simply stored creeping up each week. The basic cycle of being productive early on, then slowly drifting into extra \u201cscrolling breaks\u201d later within the month.<\/p>\n<p class=\"wp-block-paragraph\">Lastly, there was <strong>temper<\/strong>. My temper rating began at round 6.5 in week one, went barely as much as 6.6 in week two, after which sort of hovered there for the remainder of the interval. It didn\u2019t transfer dramatically, but it surely was attention-grabbing to see a small spike in week two\u200a\u2014\u200aproper earlier than my examine hours dropped and my display screen time elevated.<\/p>\n<p class=\"wp-block-paragraph\">To make issues interactive, I believed it\u2019d be nice to visualise utilizing matplotlib.<\/p>\n<figure class=\"wp-block-image size-full\"><img decoding=\"async\" src=\"https:\/\/contributor.insightmediagroup.io\/wp-content\/uploads\/2025\/10\/Screenshot-2025-10-28-103945-1.jpg\" alt=\"Weekly Habit Trends Over 30 Days\" class=\"wp-image-628021\"\/><\/figure>\n<h2 class=\"wp-block-heading\">Step 6\u200a\u2014\u200aIn search of\u00a0Patterns<\/h2>\n<p class=\"wp-block-paragraph\">Now that I had the numbers, I wished to know <em>why<\/em> my temper went up in week two.<\/p>\n<p class=\"wp-block-paragraph\">So I in contrast the weeks facet by facet. Week two had first rate sleep, excessive examine hours, and comparatively low display screen time in comparison with the later weeks. <\/p>\n<p class=\"wp-block-paragraph\">That may clarify why my temper rating peaked there. By week three, despite the fact that I slept extra, my examine hours had began to dip\u200a\u2014\u200aperhaps I used to be resting extra however getting much less carried out, which didn\u2019t increase my temper as a lot as I anticipated.<\/p>\n<p class=\"wp-block-paragraph\">That is what I preferred concerning the challenge: it\u2019s not concerning the knowledge being actual, however about how one can <em>use NumPy<\/em> to discover patterns, relationships, and small insights. Even fictional knowledge can inform a narrative whenever you take a look at it the fitting approach.<\/p>\n<h2 class=\"wp-block-heading\">Step 7\u200a\u2014\u200aWrapping Up and Subsequent\u00a0Steps<\/h2>\n<p class=\"wp-block-paragraph\">On this little challenge, I discovered just a few key issues\u200a\u2014\u200aeach about NumPy and about structuring evaluation like this.<\/p>\n<p class=\"wp-block-paragraph\">We began with a uncooked array of fictional each day habits, discovered methods to test its construction and validity, cut up it into significant chunks (weeks), after which used easy NumPy operations to research every section. <\/p>\n<p class=\"wp-block-paragraph\">It\u2019s the sort of small challenge that reminds you that knowledge evaluation doesn\u2019t all the time need to be complicated. Generally it\u2019s nearly asking easy questions like <em>\u201cHow is my display screen time altering over time?\u201d<\/em> or <em>\u201cWhen do I really feel the perfect?\u201d<\/em><\/p>\n<p class=\"wp-block-paragraph\">If I wished to take this additional (which I most likely will), there are such a lot of instructions to go:<\/p>\n<ul class=\"wp-block-list\">\n<li class=\"wp-block-list-item\">Discover the <strong>finest and worst days<\/strong> total<\/li>\n<li class=\"wp-block-list-item\">Evaluate <strong>weekdays vs weekends<\/strong><\/li>\n<li class=\"wp-block-list-item\">And even create a easy \u201cwellbeing rating\u201d based mostly on a number of habits mixed<\/li>\n<\/ul>\n<p class=\"wp-block-paragraph\">However that\u2019ll most likely be for the subsequent a part of the collection.<\/p>\n<p class=\"wp-block-paragraph\">For now, I\u2019m pleased that I received to use NumPy to one thing that feels actual and relatable\u200a\u2014\u200anot simply summary arrays and numbers, however habits and feelings. That\u2019s the sort of studying that sticks.<\/p>\n<p><strong>Thanks for studying.<\/strong><\/p>\n<p class=\"wp-block-paragraph\">Should you\u2019re following together with the collection, attempt recreating this by yourself fictional knowledge. Even when your numbers are random, the method will train you methods to slice, cut up, and analyze arrays like a professional.<\/p>\n<\/div>\n\n","protected":false},"excerpt":{"rendered":"<p>a small NumPy challenge collection the place I attempt to really construct one thing with NumPy as an alternative of simply going by means of random capabilities and documentation. I\u2019ve all the time felt that the easiest way to be taught is by doing, so on this challenge, I wished to create one thing each [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":8180,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[55],"tags":[6155,1043,5923,6157,4219,711,6156,956],"class_list":["post-8178","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-machine-learning","tag-analyze","tag-daily","tag-habits","tag-mood","tag-numpy","tag-screen","tag-sleep","tag-time"],"_links":{"self":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/8178","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=8178"}],"version-history":[{"count":1,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/8178\/revisions"}],"predecessor-version":[{"id":8179,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/posts\/8178\/revisions\/8179"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=\/wp\/v2\/media\/8180"}],"wp:attachment":[{"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=8178"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=8178"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techtrendfeed.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=8178"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}<!-- This website is optimized by Airlift. Learn more: https://airlift.net. Template:. Learn more: https://airlift.net. Template: 69d9690a190636c2e0989534. Config Timestamp: 2026-04-10 21:18:02 UTC, Cached Timestamp: 2026-06-28 02:13:53 UTC -->