<?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 Timothy Madegwa on Medium]]></title>
        <description><![CDATA[Stories by Timothy Madegwa on Medium]]></description>
        <link>https://medium.com/@timothymadegwa?source=rss-6b5c302f4417------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*7s2JUUnMQIePn3oBO_uz7Q@2x.jpeg</url>
            <title>Stories by Timothy Madegwa on Medium</title>
            <link>https://medium.com/@timothymadegwa?source=rss-6b5c302f4417------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 02:33:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@timothymadegwa/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[No Human in Limited]]></title>
            <link>https://medium.com/analytics-vidhya/no-human-is-limited-3afc2a53b3ed?source=rss-6b5c302f4417------2</link>
            <guid isPermaLink="false">https://medium.com/p/3afc2a53b3ed</guid>
            <category><![CDATA[matplotlib]]></category>
            <category><![CDATA[ineos]]></category>
            <category><![CDATA[running]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[no-human-is-limited]]></category>
            <dc:creator><![CDATA[Timothy Madegwa]]></dc:creator>
            <pubDate>Thu, 17 Oct 2019 13:20:16 GMT</pubDate>
            <atom:updated>2019-10-23T05:04:06.898Z</atom:updated>
            <content:encoded><![CDATA[<h3>No Human is Limited</h3><h4>A data analysis project on the marathon world record of under 2 hours</h4><p>Eliud Kipchoge proved No Human Is Limited when he became the first human in history to run a sub-two-hour marathon in the city of Vienna, Austria on the morning of 12th October 2019. Kipchoge ran the 42.195 KM distance in a remarkable time of 1:59:40. For more information on this record breaking run, you can visit <a href="https://www.ineos159challenge.com/news/history-is-made-as-eliud-kipchoge-becomes-first-human-to-break-the-two-hour-marathon-barrier/">here</a>. This was his second attempt to run a sub-two-hour marathon, with his first attempt in May 2017 where he clocked 2:00:25, missing his target by a mere 25 seconds.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uL7_dXWo5muGs4NnV_Gwfw.jpeg" /><figcaption>Figure 1.</figcaption></figure><p>This blog will be in two parts, in the first part I will be looking at the two fastest unofficial marathon times ran by Eliud in Breaking 2 and during the Ineos Challenge. In the 2nd part I will be comparing Eliud Kichoge’s World record time of 2:01:39 and Kenanisa Bekele’s time of 2:01:41 at the 2019 Berlin Marathon.</p><p>For my analysis, I will be using Python 3, Pandas, Matplotlib and Jupyter Notebook.</p><h4><strong>Breaking 2 vs. the Ineos Challenge</strong></h4><p>These 2 times were ran by Kenya’s Eliud Kipchoge clocking 2:00:25 in the Breaking 2 and 1:59:40 in the Ineos Challenge. I made a line plot of the average speed ran per 5 km of the race and compared how Eliud fared in the two races. To complete the entire 42.195 km race in exactly 2 hours, one needs to ran at an average speed of 21.0975 km/h (5.8604 m/s). In Breaking 2, the average speed was 21.0245 km/h (5.8401 m/s)and in the Ineos challenge the average speed was 21.1563 km/h (5.8767 m/s).</p><p>From the graph in <em>Figure 2</em>, I noted that in the Ineos Challenge, there was a more consistent pace ran throughout the race and the pace was also over the 2-hour-pace more often than not. I also saw that there was a significant increase in speed after the 40 km mark. I would attribute this to the drop of the pace car and the adrenaline rush from the excitement of being seconds away from writing history. From <em>Figure 3</em>, I also saw that the pace making was superb in the Ineos Challenge as they never went below the two hour pace.</p><p>I also saw from the graph in <em>Figure 2 </em>that in Breaking 2, the pace did not meet the 2-hour-pace and by the 35th km, the was a significant drop in the average speed mainly due to fatigue. From <em>Figure 3</em>, I saw that the pace was good until the 25–30km mark where the were off the two hour pace times.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*OJkLolFL0E1ymsYWWcekHA.png" /><figcaption>Figure 2.</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*HBeFxMX5JgWFkNnrK2ZwMw.png" /><figcaption>Figure 3.</figcaption></figure><p>From this graph I came up with the following conclusions as to why Eliud was able to run run a sub 2 hour marathon in one race and not the other.</p><ol><li>Better pace making in the Ineos Challenge.</li><li>The power of the mind not to give in to fatigue usually experienced by marathon runners after the 30 km mark.</li><li>A stronger finish to the race.</li><li>The experience of missing his mark in Breaking 2 by a mere 25 seconds.</li></ol><h3><strong>Fastest Official Marathon Times</strong></h3><p>Here I will focus on the winning times in the Berlin marathon in 2018 - 2:01:39(World record by Eliud Kipchoge) and 2019- 2:01:41(2nd fastest Marathon by Kenanisa Bekele).</p><p>From <em>Figure 4</em>, I noted that Eliud had a slow start but the he went faster when he was nearing the 20 km mark, then he seemed to have lost a bit of pace between the halfway mark and the 25 km, and he also had a strong finish at the end. Still from F<em>igure 4, </em>Bekele had a better start compared to Eliud, constantly increasing in speed till the halfway mark, where he seemed to really struggle and lost a lot of pace till the 25 km mark. After that he seemed to have renewed energy and went on to have a strong finish.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*ZXpQVmOTTZGMf62DSDL_gQ.png" /><figcaption>Figure 4.</figcaption></figure><p>It would be great to see how these two would fare with one another in a race. With this in mind, I used Bekele’s pace as a benchmark and in a bid to see how far ahead Eliud’s times were from Beleke’s time. From Figure 5, I was able to see that Bekele had a much stronger start and by the 15 km mark, he would have left Eliud behind by 8 seconds. As the race fared on, Bekele really struggled between 20–25 km and Eliud would have caught up, and he would be 6 seconds ahead of Bekele by the 25 km mark. Eliud would have gone on to ran a superb race and have a 10 second lead on Bekele by the 35 km mark and finish just 2 seconds ahead of Bekele despite his pressing on in the last 15 km.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/432/1*MfwFfC2wvI2K25_xJSWLAA.png" /><figcaption>Figure 5.</figcaption></figure><p>Having seen these 2 races, I am fairly confident that the world record of 2:01:39 can be broken by one of this two men (before 2021), since non of them had a perfect race when they ran those times.</p><p>Data Sources:</p><ol><li><a href="http://results.scc-events.com/2018/?content=detail&amp;fpid=list&amp;pid=list&amp;idp=00001705C9AF74000047E482&amp;lang=EN&amp;event=MAL&amp;search%5Bsex%5D=M&amp;search%5Bage_class%5D=%25&amp;search_event=MAL">Berlin marathon 2018</a></li><li><a href="https://berlin.r.mikatiming.com/2019/?content=detail&amp;fpid=list&amp;pid=list&amp;idp=00001705C9AFB000004BB4CD&amp;lang=EN&amp;event=MAL&amp;search%5Bsex%5D=M&amp;search%5Bage_class%5D=%25&amp;search_event=MAL">Berlin Marathon 2019</a></li></ol><p>3. Information -<a href="https://www.ineos159challenge.com/news/history-is-made-as-eliud-kipchoge-becomes-first-human-to-break-the-two-hour-marathon-barrier/">Ineos Challenge</a> and <a href="https://en.wikipedia.org/wiki/INEOS_1:59_Challenge">Ineos Data</a></p><p>If you would like the code I used to do this analysis and the data, feel free to reach out to me on my email timothymadegwa@gmail.com</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3afc2a53b3ed" width="1" height="1" alt=""><hr><p><a href="https://medium.com/analytics-vidhya/no-human-is-limited-3afc2a53b3ed">No Human in Limited</a> was originally published in <a href="https://medium.com/analytics-vidhya">Analytics Vidhya</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[BASIC IMAGE EDITING WITH PYTHON]]></title>
            <link>https://medium.com/@timothymadegwa/basic-image-editing-with-python-f1a5a3171141?source=rss-6b5c302f4417------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1a5a3171141</guid>
            <category><![CDATA[matplotlib]]></category>
            <category><![CDATA[image-processing]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[image-editing]]></category>
            <dc:creator><![CDATA[Timothy Madegwa]]></dc:creator>
            <pubDate>Fri, 11 Oct 2019 13:47:02 GMT</pubDate>
            <atom:updated>2022-04-04T06:19:02.367Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>BASIC IMAGE EDITING WITH PYTHON</strong></p><p>Hello there, Its been a while since my last post so today I’ve decided to write a simple post on how your edit/manipulate an image using Python. In this post, I am going to use a popular python library called Matplotlib to do some basic image manipulation.</p><p><strong>REQUIREMENTS</strong></p><ol><li>Python 3.6 or later (I used Python 3.6.4 for this post)</li><li>Matplotlib 2.1.2</li><li>Jupyter notebook</li></ol><p>You do know how to check your Python and Matplotlib versions? Well don’t worry, I got you. To check your version of python, open your command prompt or terminal and write this command <strong><em>python - -version.</em></strong></p><p>For Matplotlib:</p><ol><li>open your terminal or command prompt</li><li>type in the ‘<em>python’ command</em></li><li>type in ‘<em>import matplotlib’ and press enter</em></li><li>type in <em>‘matplotlib.__version__’ and press enter</em></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/977/1*ARy4Kk74lg1oB8I_x95RGA.png" /><figcaption>checking the Python and Matplotlib versions</figcaption></figure><p>We start off by importing Matplotlib.pyplot with its alias plt, and also as an alternative way of importing our image, we can also import matplotlib.image as mpimg. Having done that, we can now load our image using pyplot’s imread() function as shown in figure 1 below. Matplotlib is built on numpy and so any image loaded through it is stored as a numpy array.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/667/1*qUu0LmKI2NYLxojE6moxXQ.png" /><figcaption>figure 1</figcaption></figure><p>From figure 1, we can see that the image is a 3-D numpy array with 1926 rows and 2694 columns. The other 3 at the end is just the RGB values for the image. Here, the image is stored with values ranging from 0 to 255, representing the various RGB values.</p><p>Let’s have a look at the image using pyplot’s imshow method.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/840/1*H3m2EDoGKOu7-gIREA4gjw.png" /><figcaption>Figure 2</figcaption></figure><p>Now, I can apply various color maps(filters) on the image and see how it affects the image.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*s1LcJ9BQ4f2FUM_iYPi_Jg.png" /><figcaption>Figure 3</figcaption></figure><p>I can also collapse the image by taking the average of the RGB values and apply the color maps(filters) on the same image as show in the code below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/930/1*G5DywvbFSSnNnCFdKIZaSg.png" /><figcaption>Figure 4</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/587/1*SeMRPi4wMTkVEvYxJ8oPzw.png" /><figcaption>Figure 5</figcaption></figure><p>Here is a list of the different color map values you can use to edit your picture.</p><blockquote>[Accent, Accent_r, Blues, Blues_r, BrBG, BrBG_r, BuGn, BuGn_r, BuPu, BuPu_r, CMRmap, CMRmap_r, Dark2, Dark2_r, GnBu, GnBu_r, Greens, Greens_r, Greys, Greys_r, OrRd, OrRd_r, Oranges, Oranges_r, PRGn, PRGn_r, Paired, Paired_r, Pastel1, Pastel1_r, Pastel2, Pastel2_r, PiYG, PiYG_r, PuBu, PuBuGn, PuBuGn_r, PuBu_r, PuOr, PuOr_r, PuRd, PuRd_r, Purples, Purples_r, RdBu, RdBu_r, RdGy, RdGy_r, RdPu, RdPu_r, RdYlBu, RdYlBu_r, RdYlGn, RdYlGn_r, Reds, Reds_r, Set1, Set1_r, Set2, Set2_r, Set3, Set3_r, Spectral, Spectral_r, Vega10, Vega10_r, Vega20, Vega20_r, Vega20b, Vega20b_r, Vega20c, Vega20c_r, Wistia, Wistia_r, YlGn, YlGnBu, YlGnBu_r, YlGn_r, YlOrBr, YlOrBr_r, YlOrRd, YlOrRd_r, afmhot, afmhot_r, autumn, autumn_r, binary, binary_r, bone, bone_r, brg, brg_r, bwr, bwr_r, cool, cool_r, coolwarm, coolwarm_r, copper, copper_r, cubehelix, cubehelix_r, flag, flag_r, gist_earth, gist_earth_r, gist_gray, gist_gray_r, gist_heat, gist_heat_r, gist_ncar, gist_ncar_r, gist_rainbow, gist_rainbow_r, gist_stern, gist_stern_r, gist_yarg, gist_yarg_r, gnuplot, gnuplot2, gnuplot2_r, gnuplot_r, gray, gray_r, hot, hot_r, hsv, hsv_r, inferno, inferno_r, jet, jet_r, magma, magma_r, nipy_spectral, nipy_spectral_r, ocean, ocean_r, pink, pink_r, plasma, plasma_r, prism, prism_r, rainbow, rainbow_r, seismic, seismic_r, spectral, spectral_r, spring, spring_r, summer, summer_r, tab10, tab10_r, tab20, tab20_r, tab20b, tab20b_r, tab20c, tab20c_r, terrain, terrain_r, viridis, viridis_r, winter, winter_r]</blockquote><p>I can also compress the image by taking every 3rd pixel of the image as shown in the figure below. I’ll start by checking the shape of the image(pixels) before and after compressing. From that I can see that the shape chaged from (1926,2694) to (642,898).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*GS_nGxS8tV8Xk5oPJRJISw.png" /><figcaption>Figure 6</figcaption></figure><p>Finally I can save my compressed and filtered image using the code below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/821/1*nEQSB2qTtoNEHqtlhEMghg.png" /><figcaption>Figure 7.</figcaption></figure><p>I hope you have learnt something from this post and you can now edit your own photo using Matplotlib.</p><p>For advanced image processing, I found an awesome article that you can read <a href="https://neptune.ai/blog/image-processing-python">here</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1a5a3171141" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[IcodeAI Interview]]></title>
            <link>https://medium.com/@timothymadegwa/icodeai-interview-8ab8eb8f2132?source=rss-6b5c302f4417------2</link>
            <guid isPermaLink="false">https://medium.com/p/8ab8eb8f2132</guid>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[icodeai]]></category>
            <category><![CDATA[interview]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Timothy Madegwa]]></dc:creator>
            <pubDate>Mon, 04 Mar 2019 16:34:14 GMT</pubDate>
            <atom:updated>2019-03-04T16:34:14.196Z</atom:updated>
            <content:encoded><![CDATA[<p>I was invited for an interview by IcodeAI on Thursday 28th February 2019. Before the interview, I had completed an assignment that required me to write two programs and also test the programs.</p><p>On arrival at the venue for the interview I was met with Allan as I was walking towards the venue and he welcomed me with warming smile. The first task I had was a group challenge that required me to work together with two other people and tackle a survival problem. In this task, I got to work with Sharon and Stephen and we were able to work together an rank items that would help us survive in the desert should we be stranded there after a plane crush.</p><p>During this task, I got to learn that different people prioritize different things. For example, I had a preference for hunting and moving towards the flight path and a nearby station while others had a preference of moving towards the flight path with the hope of being rescued. This is how things are in a real life working situation as I know I will have to work with people with different objectives and styles of handling an issue. What is important is that a solution is reached despite all my plans and objectives are not taken up.</p><p>After this session, we had the individual interviews where I selected to go first. As part of the interview I had to defend the code to the programs I had written. I explained my codes and answered all the questions I had been asked by the interview panel. This was a very unique and interesting interview as we were all present as me and my fellow interviewees had their individual interviews.</p><p>This enabled me to see and listen in to how other people do their interviews and I also got to learn on how they tacked their programming problem. The biggest learning point for me was getting to note about <strong>Regular Expressions</strong> and I later on went to read more on it.</p><p>In conclusion, it was a good day as I got to interact with different people during the interview and I also got to meet one of my students from a previous job. I am super excited and ready to learn with the IcodeAI and I really hope and pray that I get the opportunity to pursue my passion with such an amazing team.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8ab8eb8f2132" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ANALYSIS OF HEART DISEASE AND HOW IT AFFECTS THE SEXES.]]></title>
            <link>https://medium.com/@timothymadegwa/analysis-of-heart-disease-and-how-it-affects-the-sexes-8c68da6dceda?source=rss-6b5c302f4417------2</link>
            <guid isPermaLink="false">https://medium.com/p/8c68da6dceda</guid>
            <category><![CDATA[health-analytics]]></category>
            <category><![CDATA[data-analysis]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[health]]></category>
            <dc:creator><![CDATA[Timothy Madegwa]]></dc:creator>
            <pubDate>Mon, 13 Aug 2018 15:03:49 GMT</pubDate>
            <atom:updated>2018-08-13T15:03:49.858Z</atom:updated>
            <content:encoded><![CDATA[<p>ANALYSIS OF HEART DISEASE AND HOW IT AFFECTS THE SEXES.</p><p>Hello, I set out to find out the chances of getting heart disease based on your sex. Is there a difference between the sexes?</p><p>I got my hands on an online data set of 303 patients who’s various heart and heart function measurements were taken and in the end they were either declared to have a heart disease or not. Some of the parameters included heart rates, blood pressure, angina, age, among many others. But for this read I will mainly focus on the sex and angina and how it affects the probability of being diagnosed with heart disease. Below is a summary of the data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*S4q6d6ZPMnaSOefK-ii4PQ.png" /><figcaption>fig 1. overview of the data</figcaption></figure><p>Using python, I did an exploratory analysis to try and get to know more about my data as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4KZn8u5H5Kg_SFW9WGC85g.png" /><figcaption>fig 2 . Descriptive statistics about the data</figcaption></figure><p>I then went on to find out the composition of the data set in terms of how many men and women are in the data set and also how many of the people in there have a condition called angina.<em> </em><strong><em>Angina </em></strong><em>simply refers to a type of chest pain caused by reduced blood flow to the heart and it is usually a symptom of coronary artery disease</em>. It contained the following.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hs_ChZsPlV7wkAuj0H2-gw.png" /><figcaption>fig 3. Summery of the composition of the data set</figcaption></figure><p>Upon further analysis I got to find out that the data set contained 96 women and 207 men making a total of 303. From the women, I found out the only 24 women (25% of the total women) were found to be sick and 72 women (75% of the total women) were found to be healthy. On the male side, I found out that 114 men (about 55% of the total men) were diagnosed with heart disease and only 93 men (about 45% of the total men)were found to be healthy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/389/1*g1jpmZzOZ8Jjre1jgeOTNg.png" /><figcaption>fig 4. A graph showing the health status based on sex</figcaption></figure><p>Moving o to the analysis of angina between the sexes and its effects on the probability on the chances of one having heart disease. Here I was able to find out that about 77% of the women in the data set do not suffer from angina and 23% of them suffer from it. On the male side I found out that there are about 63% of the men in this data set do not suffer from angina and 37% of them do as seen in figure 6.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/462/1*MQSLkM91Xqre-nnVC7K3Hg.png" /><figcaption>fig 5. Angina in the sexes</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/823/1*bblrctKfJAiQ_xXW7x9Fiw.png" /><figcaption>fig 6.</figcaption></figure><p>Also from the data I found out that about 70% of the people not having angina were were declared healthy and the other 30% were diagnosed with heart disease. Also from those who were suffering from angina, 77% of them went on to be diagnosed with heart disease while only 23% of those who had angina were declared to be healthy.</p><p>Also age is a very vital factor in being diagnosed with a heart condition and upon analysis, I found that approximately 60% of the people below 60 years in this data set are healthy while about 58% of those above 60 years old have a heart condition as seen below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/692/1*Yx3KelBEWowa1aMcO9_4qA.png" /><figcaption>fig 7.</figcaption></figure><p>From this analysis I got to see that it is more likely for men to be diagnosed with heart disease than women as only 25% of the women had heart disease as compared to 55% of the men in the data set. I also found out that most people suffering from angina have an underlying heart problem.</p><p>I attribute the difference in probability of getting heart disease between the sexes to the following 2 major reasons.</p><ol><li>The difference in lifestyle choices among the men and women, where men tend to drink more alcohol and smoke more which lead to heart diseases in the long run as compared to women who drink less and eat healthier hence lower chances of lifestyle diseases.</li><li>Women tend to be more active especially at a more advanced age (after retirement)while men tend to be less active as compared to the women who keep busy with house chores and other small activities.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8c68da6dceda" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>