<?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 Johannes Wohlenberg on Medium]]></title>
        <description><![CDATA[Stories by Johannes Wohlenberg on Medium]]></description>
        <link>https://medium.com/@johanneswohlenberg?source=rss-8644189ad630------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*PjTlmo5gu4OGIO4VOSX7gQ.jpeg</url>
            <title>Stories by Johannes Wohlenberg on Medium</title>
            <link>https://medium.com/@johanneswohlenberg?source=rss-8644189ad630------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 07:01:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@johanneswohlenberg/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[The psychological Gain of Bouldering]]></title>
            <link>https://johanneswohlenberg.medium.com/the-psychological-gain-of-bouldering-ab5a6c5e7aa1?source=rss-8644189ad630------2</link>
            <guid isPermaLink="false">https://medium.com/p/ab5a6c5e7aa1</guid>
            <category><![CDATA[life]]></category>
            <category><![CDATA[climbing]]></category>
            <category><![CDATA[bouldering]]></category>
            <category><![CDATA[sports]]></category>
            <category><![CDATA[mindfulness]]></category>
            <dc:creator><![CDATA[Johannes Wohlenberg]]></dc:creator>
            <pubDate>Wed, 04 Aug 2021 10:18:56 GMT</pubDate>
            <atom:updated>2021-10-07T18:31:50.035Z</atom:updated>
            <content:encoded><![CDATA[<h4>A personal evaluation</h4><h4>or how a Sport got me out of a dark place</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*cmAMks8TL_yadbOY" /><figcaption>Photo by <a href="https://unsplash.com/@picsbyjameslee?utm_source=medium&amp;utm_medium=referral">James Lee</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Back in 2017, I felt miserable. In retrospect, I think it had multiple factors. At that point I was out of freshman year at university, so my motivation to study was on a steady decline. I just felt like I was imprisoned in a hamster wheel. Additionally, I fell in love with a girl, that did not feel the same way for me, as I felt for her. Love is a hell of a drug, it can be a motor on your life as easy as it can bring it to a standstill. I remember it devastating me quite a lot. Instead of doing something purposefully, I was only hanging around with the boys. This wasn’t any help as we did literally nothing. Life felt without purpose.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*jCfocR8zowq-Mfvx" /><figcaption>Photo by <a href="https://unsplash.com/@juliatheuer?utm_source=medium&amp;utm_medium=referral">Julia Margeth Theuer</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>That was when one of my friends asked me to go Bouldering with him. To all who don’t know, Bouldering is a version of climbing where you climb short very hard routes without a rope. Most routes are not higher than 2–4 meters. This was the beginning of my great love for this sport. Let me explain to you, what got me hooked until today.</p><h3>Far more than just some sport</h3><h4>Being successful</h4><p>I don’t know if it is just me or my generation or if most people feel this way, but getting a success experience became harder the older I got. It does not matter what you do, somebody does it better. I would not care if it would not happen day in day out. What I needed back in 2017 was a feeling of success, that would prevail. When I go into our local climbing gym, there are 200 routes to climb. I will leave, no matter what happens, with at least 50 being climbed. Never did I go home with a feeling of being unsuccessful.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*7gouIiw8XH37ltS2" /><figcaption>Photo by <a href="https://unsplash.com/@markusspiske?utm_source=medium&amp;utm_medium=referral">Markus Spiske</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Apart from that, what I think many young people face, is that we are somewhat without a goal. There is no light at the end of the tunnel. I rarely meet people that are determined to achieve a certain goal in their life. This is bad, as it makes you unhappy and unfocused. That is why Parents are more stressed but also happier than non-parents. It is worth going to your 9–5 job when you come home and see your kid. You have a purpose, you know why you are doing something. When I am climbing, I have the goal to get on top of the route. If necessary I will try it 100 times. Experiencing this determination to reach a certain goal naturally blurs out all the things that bother me normally. It frees my mind unlike anything else.</p><h4>Friendships and Teamwork</h4><p>When I started climbing, quite fast a circle of around 5 people formed. Some of them knew each other until then, some did not. All were very nice. I never observed an unfriendly climber, which makes me believe they do not exist. Obviously, there is competition, but no bad blood. We always try to push ourselves and cheer on anyone who does a hard route. Where we come to another thing.</p><p>Bouldering is actually a Team sport. When routes get harder you really have to think about how you approach them before actually putting your hands on the wall. Each route has a chokepoint, that is especially hard and that defines the route’s grade. Often one has to try many times to figure out what works best at the wall. That is when my friends and I would alternate between attempts. When one would figure something out, he would tell the others. The result is, that reaching the top is actually a team effort. There is nothing greater about figuring out a route together.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*5A4E1Qdm8a6vbS83" /><figcaption>Photo by <a href="https://unsplash.com/@tlisbin?utm_source=medium&amp;utm_medium=referral">Tommy Lisbin</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Small Anecdote: I once tried a route around 50 times. I actually was so wasted that I saw stars, that’s why I had to leave it for next time. That night I dreamed about how to solve the puzzle, which was the right way. I did the route first try the next time we were there.</p><h4>Trust</h4><p>One thing that I am struggling with all my life is trusting in myself. When climbing you are forced to do so. In the gym, I often push myself to do something that feels wrong. Still, I do it, as I believe in my own capabilities. This helped me so much to trust myself and to learn that sometimes you have to just do it. Sometimes something feels too much to handle but if you push through it will work out.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*4fxgXArGnf-rgouW" /><figcaption>Photo by <a href="https://unsplash.com/@mike?utm_source=medium&amp;utm_medium=referral">Mike Kotsch</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>When climbing outside, there is another dimension to this. Climbing can be very dangerous. In the gym, there are a whole lot of security features, and routes are deterministic. Outside you really have to focus and rely on others that secure you. In Bouldering, we lay crashpads below the route while your friends try to push you onto them if you are in danger to miss them while falling. Sounds worse than it actually is. Thing is, you have to know when to stop when you are too exhausted or when a route is beyond your capabilities. Also, a good thing to learn. After all, you can train and retry, the boulder won’t run away.</p><h3>some final words</h3><p>I purposefully did not write about the physical gain of Bouldering. Obviously, your whole body gets stronger, especially your core, back, and arm muscles. Additionally, it is a great way to lose weight, as each kilo of fat has to be pulled up the wall. The thing is, that for me the psychological influences of Bouldering exceed the physical ones by far. I only realized how much I needed to do sport when I actually tried it again. It made me change my Mindset for the better, and helped me learning crucial lessons while having a difficult time in life. With that, I want to thank you for reading and urge you to do some sport. Even if it is not Bouldering, it will help you to get a free mind and therefor be happier in life.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ab5a6c5e7aa1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Regional and Online Learnable Fields]]></title>
            <link>https://medium.com/data-science/regional-and-online-learnable-fields-cbb18b74e01e?source=rss-8644189ad630------2</link>
            <guid isPermaLink="false">https://medium.com/p/cbb18b74e01e</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[clustering]]></category>
            <dc:creator><![CDATA[Johannes Wohlenberg]]></dc:creator>
            <pubDate>Tue, 13 Jul 2021 18:48:55 GMT</pubDate>
            <atom:updated>2021-09-21T20:45:01.497Z</atom:updated>
            <content:encoded><![CDATA[<h4><strong>A new, not so new, clustering algorithm</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/779/1*wNmpuTSlUNaqlAG4pSfqxg.png" /><figcaption>(Image by author)</figcaption></figure><p>This article will guide you through Regional and Online Learnable Fields. A seemingly unrecognized clustering algorithm, that provides several advantages over k-Means and k-Nearest-Neighbours, from which it originates.</p><h3>Regional and Online Learnable Fields</h3><p>First proposed by Rolf Schatten, Nils Goerke, and Rolf Eckmiller in 2005, the Regional and Online Learnable Field is an online and unsupervised clustering technique [1]. The general idea is to approximate our datapoints with so-called ROLF-Neurons, which can be connected to form clusters in a later step. Originating from k-Means and k-Nearest-Neighbors, this algorithm does aim to improve on them. Let us first see, where the former can be enhanced.</p><h3>Where can k-Means and KNN be improved?</h3><ol><li>A Common Problem with the original k-Means Algorithm is that we have to choose the number of clusters k in advance. While sometimes we can make an educated guess, most of the time we have to resort to some form of trial and error. This takes time, and it would be better to incorporate the choosing of k into the clustering process itself.</li><li>Another problem is, that k-Means is unable to cluster certain shapes, like two concentric circles or two interlocked half-moons. In general, k-Means fails when clusters are not circular or when their centroids are close to each other.</li><li>k-Means is not online adaptable. Say you trained k-Means on two clusters and now are presenting it with datapoints of a third one. These points would be assigned to the two clusters found during training. This is not desirable, and it would be far better if the algorithm would create a new cluster for said points, or mark them as ‘unknown’.</li><li>Additionally, kNN faces the problem of complexity. To assign a datapoint to a cluster, we have to calculate its distance to all training-points. You can imagine, that if we have a great number of training-points, this becomes computationally inefficient quite fast. So here, we have to find a way to reduce the amount of distance calculations made.</li></ol><h4>The ROLF-Neuron</h4><p>The Heart of Regional and Online Learnable Fields are the so-called ROLF-Neurons. These act as prototypes to our datapoints, and have an area they are responsible for. This area is called the perceptive field. The ROLF-Neuron consists of 3 Parameters:</p><ol><li>Center <em>c</em>, that defines the position of the neuron in space.</li><li>Width <em>σ</em>, that defines the width of each neuron.</li><li>Perceptive Field<em> r = p </em>⋅ <em>σ</em>, which defines the area for which it is responsible. Set initially, the constant <em>p</em> is equal for all neurons. It defines the ratio between the perceptive field and the width of each neuron.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SaBLckJy-komC52-HpUgag.png" /><figcaption><strong>p = 2 </strong>(Image by author)</figcaption></figure><h3>Learning the Network</h3><p>This essentially works in two steps, first, we have to find the ROLF-Neurons or Prototypes in our training data. After which we build a Neighborhood graph between them, that finally defines the clusters.</p><h3>How to find the Rolf-Neurons?</h3><p>First, we iteratively go through all training patterns and look if they are inside the perceptive field of an already existing Neuron. If it is in the Perceptive field of multiple Neurons, we choose that Neuron, which is closest to the pattern. After we decided on this so-called ‘winning neuron’, we adapt its center <em>c</em> and width <em>σ</em>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*p2THuOoYz0n7a8PwqvykBQ.png" /><figcaption>(Image by author)</figcaption></figure><p>If the pattern does not lie in the perceptive field of any existing neuron, we create a new one according to the initialization strategy. This strategy has to be chosen initially. We will discuss the details of this later.</p><h3>How to adapt the Winning Neuron?</h3><p>Let <em>x</em> be a training pattern and <em>c </em>be the center of the winning Neuron. To adapt center <em>c</em> and width <em>σ</em> we first have to calculate the distance <em>d</em> between <em>c</em> and <em>x</em>. Afterward, we move <em>c</em> towards <em>x</em> and adapt <em>σ</em> towards <em>d</em>. Finally, we recalculate the perceptive field.</p><figure><img alt="test" src="https://cdn-images-1.medium.com/max/1024/1*vmgtsN5Yy0ta6StPXh-EGQ.png" /><figcaption>(Image by author)</figcaption></figure><p>From the formulas, we can see the use of the constant parameter <em>p</em>. It allows the neuron to accept patterns outside <em>σ. </em>If the distance between x and c is greater than <em>σ, </em>the former gets increased<em>. </em>In the opposite case, it gets decreased. Without<em> p,</em> the perceptive field could only shrink, as exclusively points within <em>σ</em> would be accepted.</p><h3>How to initialize a new Neuron?</h3><p>When we initialize a new neuron, we always set <em>c</em> to be at pattern <em>x</em>. The value we change is the neuron’s width<em> σ</em>. This can be set in four different ways.</p><ol><li><strong>Init-σ →</strong> Initialize <em>σ</em> to a constant value</li><li><strong>Minimum-σ </strong>→ Initialize<em> σ</em> as the minimal <em>σ</em> of all already existing neurons</li><li><strong>Maximum-σ </strong>→ Initialize <em>σ</em> as the maximal <em>σ</em> of all already existing neurons</li><li><strong>Mean-σ</strong>→ Initialize <em>σ</em> as the mean <em>σ</em> overall already existing neurons</li></ol><p>Now, the observant reader might think: How do I initialize the first neuron if I choose mean-σ as my strategy. After all, there are no σ-values to calculate the mean over. Well, this is correct. The σ of the first neuron always has to be set by a predefined value. All following will then be set by your chosen strategy.</p><h3>Building the Neighborhood</h3><p>In the second step of the Learning algorithm, we want to group our previously found neurons into clusters. This is done by building a Neighborhood graph, where neurons with overlapping perceptive fields are connected with an edge. Mathematically speaking, two neurons are connected if their center distance is smaller than the sum of their perceptive fields (radii).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EtWWPO7Kss0oa1P5goi5uw.png" /><figcaption>(Image by author)</figcaption></figure><p>Now all neurons, that can be connected via a sequence of edges, are of the same cluster. The union of their perceptive fields is the total area, in which new datapoints are assigned to said cluster during prediction.</p><h3>Advantages of ROLF</h3><ol><li>The algorithm can choose the number of clusters <em>k</em> on its own.</li><li>The algorithm is not restricted by the shapes of clusters. Especially the problem cases for k-Means, the interlocked half-moons and the concentric circles can be clustered with ROLF. Examples will be given in the following section.</li><li>By representing the training datapoints with ROLF-neurons, only distance calculations for the former have to be performed. Additionally, exclusively neurons have to be stored, while patterns will only be presented once, and can then be discarded. This also reduces memory usage.</li><li>The algorithm can detect outliers on its own, on which it then can act accordingly.</li></ol><h3>Performance</h3><p>Now I want to show you several examples of how the Regional and Online Learnable Field does perform in practice.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*79lxpIE01YTw908NRUdQ-g.png" /><figcaption>20000 points, 219 neurons (Image by author)</figcaption></figure><p>In the given examples, you can see how ROLF can cluster the two failing cases of k-Means. For both examples, a learning rate of 0.05 for <em>c</em> and <em>σ</em> was used. New neurons were initialized with the Minimum-σ strategy. The first Neuron was initialized with σ = 0.4, while <em>p</em> was set to 2. The neighborhood graph is visualized by the black lines. Both datasets consist of 20000 points and were reduced to about 1% of neurons. The Green and Blue area visualize where points would be assigned to the respective cluster.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IyJJRnlidzO8BUWrY5g0qA.png" /><figcaption>20000 points, 239 neurons (Image by author)</figcaption></figure><h3>Remarks</h3><ol><li>The dimension of center c for the ROLF neurons does not have to be 2. In the original paper, ROLF was used to cluster points from a 720-dimensional input space [1].</li><li>The code used to generate the examples can be found <a href="https://github.com/JoWohlen/Medium_Code/tree/main/ROLF">here</a>.</li></ol><h3>Sources:</h3><p>[1] Schatten R., Goerke N., Eckmiller R. (2005) Regional and Online Learnable Fields. In: Singh S., Singh M., Apte C., Perner P. (eds) Pattern Recognition and Image Analysis. ICAPR 2005. Lecture Notes in Computer Science, vol 3687. Springer, Berlin, Heidelberg. <a href="https://doi.org/10.1007/11552499_9">https://doi.org/10.1007/11552499_9</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cbb18b74e01e" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/regional-and-online-learnable-fields-cbb18b74e01e">Regional and Online Learnable Fields</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 versions of k-Means]]></title>
            <link>https://medium.com/data-science/three-versions-of-k-means-cf939b65f4ea?source=rss-8644189ad630------2</link>
            <guid isPermaLink="false">https://medium.com/p/cf939b65f4ea</guid>
            <category><![CDATA[k-means-clustering]]></category>
            <category><![CDATA[macqueen]]></category>
            <category><![CDATA[hartigan]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[clustering]]></category>
            <dc:creator><![CDATA[Johannes Wohlenberg]]></dc:creator>
            <pubDate>Mon, 21 Jun 2021 12:34:28 GMT</pubDate>
            <atom:updated>2023-04-02T01:53:51.632Z</atom:updated>
            <content:encoded><![CDATA[<h4>Hartigan-Wong, MacQueen, Lloyd</h4><h4>A short visual guide to the 3 implementations of k-Means</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5_Ve34hUjw92WfjxvYeJsQ.png" /><figcaption>(Image by author)</figcaption></figure><p>In this article we will speak about Lloyd’s, MacQueen’s and Hartigan-Wong’s k-Means. I will not only provide you with pseudocode for all the implementations, but you will also get a visualization of how the implementations are working internally.</p><h3>K-Means</h3><p>In clustering, we have a set of datapoints, that we want to assign to clusters based on their similarity. This should be done in such a way, that the objective function (Sum of squares,..) is minimized. There are many clustering algorithms, that all have their advantages and disadvantages. K-Means is probably the most known of them. Here we have centroids as prototype for our clusters. Each datapoint belongs to the centroid (and there for cluster) that is closest to him. How we algorithmically find those centroids, you will see in the following article.</p><h3>Lloyd’s k-Means</h3><p>Lloyd is the most widely known Implementation of k-Means. When students first come into contact with clustering, they almost certainly learn Lloyd’s k-Means. This is, as Lloyd is both, easy to understand and easy to implement. Let’s get the Elephant out of the room, and look how this algorithm actually works.</p><p>Lloyd initially chooses k datapoints as centroids, at random. After that, all datapoints are assigned to their closest centroid following the recalculation of centroids as mean over all their assigned datapoints. Lloyd loops over these last two steps until no point changes its assignment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/780/1*wSeVH343-ULAMhzelEbcgg.png" /><figcaption>(Image by author)</figcaption></figure><p>Unfortunately, Lloyd does suffer greatly from a problem many clustering algorithms face. That is, that the forming of clusters is heavily influenced by the choosing of initial centroids. Or in more mathematical terms. Lloyd might get stuck in a local optima, depending on its initialization.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*iYXJamN3tXmW7hPC_4hmww.gif" /><figcaption>(Image by author)</figcaption></figure><h3>MacQueen’s k-Means</h3><p>When Lloyd updates the assignments of datapoints, it does not update the centroids. This is problematic, as with each new assignment, the centroid changes its position. It can happen that a datapoint is wrongfully assigned to a centroid simply because said centroid was not updated. MacQueen tries to cope with this, as it updates the centroids with each new assignment. Obviously this results in more computation time.</p><p>MacQueen initializes the same way as Lloyd. The only difference between both is, that we iterate over the datapoints, and when reassigning them, we recalculate the affected centroids. This we also do in a loop until no point changes its assignment.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*Kt8QxvGnjgPPaiPOu8Momg.png" /><figcaption>(Image by author)</figcaption></figure><p>In the following example, we can see, that MacQueen does find very good assignments within the first iteration over all datapoints. The second iteration only reassigns a small quantity of initially wrongly assigned datapoints. This behavior is typical for MacQueen’s k-Means [1].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*WIhhEmaNjp0tDlJtYuZjhw.gif" /><figcaption>(Image by author)</figcaption></figure><h3>Hartingan-Wong k-Means</h3><p>Remember the initialization Problem of Lloyd? MacQueen somewhat suffers also from this. After all, MacQueen does not choose initial centroids differently than Lloyd. Hartigan-Wong on the other hand, initially assigns all datapoints to random centroids. After which the later are calculated as the mean of their assigned datapoints. This results in all centroids being initially more or less at the same spot. Hartigan-Wong is les prone, to converge to a local optima than Lloyd [2].</p><p>In Hartigan-Wong, from all centroids we choose that one as assignment, where said assignment results in the smallest objective function. In the example below, we used the sum of squared distances from each datapoint to its assigned center as the objective function. The result is, that a datapoint can be assigned to a centroid even if that centroid is not its closest one. This can be viable, if it decreases the objective function and therefor increases the total quality of our clustering.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cut8tJKpPSJMgZd03BPciQ.png" /><figcaption>(Image by author)</figcaption></figure><p>In this case, convergence means, that no point changed its assignment. Obviously, this method results in the highest computation time of all three proposed implementations. Hartigan-Wong is much more sophisticated as Lloyd or MacQueen, as it updates centroids when points are reassigned and as it considers the broader impact of assigning a point to a centroid.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*s7VjG4lffxKnxuilNzaEGw.gif" /><figcaption>(Image by author)</figcaption></figure><h3>Conclusion</h3><p>Now you learned about the 3 different implementations of k-Means. Some more sophisticated than others. If you are now unsure which one to implement next, I can only say that it depends. If your data is differentiated somewhat clean, like in the example I used, you are probably faster with MacQueen or Lloyd.</p><p>I hope I could help you, and I am happy to see you next time.</p><p>Finaly I want to mention, that there are multiple ways to choose initial centroids to improve Lloyd and MacQueen. If you want to know more, I suggest the following article.</p><p><a href="https://medium.com/analytics-vidhya/comparison-of-initialization-strategies-for-k-means-d5ddd8b0350e">Comparison of Initialization strategies for k-Means</a></p><h3>References</h3><p>[1] Morissette, Laurence &amp; Chartier, Sylvain. (2013). The k-means clustering technique: General considerations and implementation in Mathematica. Tutorials in Quantitative Methods for Psychology. 9. 15–24. 10.20982/tqmp.09.1.p015.</p><p>[2] Slonim, Noam &amp; Aharoni, Ehud &amp; Crammer, Koby. (2013). Hartigan’s K-means versus Lloyd’s K-means: is it time for a change?. Proceedings of the 23rd International Joint Conference on Artificial Intelligence. 1677–1684.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cf939b65f4ea" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/three-versions-of-k-means-cf939b65f4ea">3 versions of k-Means</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Functional Principal Component Analysis and Functional Data]]></title>
            <link>https://medium.com/data-science/functional-principal-component-analysis-and-functional-data-91d21261ab7f?source=rss-8644189ad630------2</link>
            <guid isPermaLink="false">https://medium.com/p/91d21261ab7f</guid>
            <category><![CDATA[hands-on-tutorials]]></category>
            <category><![CDATA[principal-component]]></category>
            <category><![CDATA[functional-data-analysis]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[editors-pick]]></category>
            <dc:creator><![CDATA[Johannes Wohlenberg]]></dc:creator>
            <pubDate>Wed, 09 Jun 2021 18:12:51 GMT</pubDate>
            <atom:updated>2021-06-11T16:26:56.876Z</atom:updated>
            <content:encoded><![CDATA[<h4><a href="https://towardsdatascience.com/tagged/hands-on-tutorials">Hands-on Tutorials</a></h4><h4>A short dive into the world of functional data, and in particular into functional principal component analysis.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*AKwrh0GkjURrmSNxv8W07Q.png" /><figcaption>A typical example of functional data (Image by author)</figcaption></figure><h3>Functional Data</h3><p>What the heck is functional data?</p><p>Say you are measuring the temperature in your hometown each day for multiple years. If you then look at the accumulated data, you might come to the conclusion, that the temperature somewhat behaves similar over one year. Well, this is quite obvious, we live by this pattern after all. The weather is governed by time. In fact, one could say, that there is an underlying function of time, that gives rise to your measurements. Now in functional data analysis, we do not interpret our measured data as a sequence of observations, but as a single function or curve. This has multiple upsides over the traditional timeseries view.</p><ol><li>A function usually can be evaluated at any point in time.</li><li>We can analyze the derivatives of functions.</li><li>Functions can be registered very easily to a common timescale.</li><li>functions can provide a much more natural and intuitive view on our data.</li><li>Measurements do not have to be taken at the same point in time to be comparable.</li></ol><p>Point 5 is in fact a common problem. It often happens that you want to compare timeseries, but they have measurements not taken at the same time, or one has more measurements than the other. Comparing those would then be problematic. If we view our data as function, comparison becomes much easier.</p><h3>Aren’t we forgetting something here?</h3><p>Functions are continous, measurements are not.</p><p>Well yes, it is in fact true, that measurements are not continuous. But we can estimate the underlying functions to our data. This way we are also able to induce smoothing, which can be desirable to reduce noise. Now how can this be done, you might ask? A common approach would be to use basis expansion. Here we would represent our measurements via a linear combination of basis functions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*bUHRwsWf0B4DGvMuLWRfkg.png" /><figcaption>(Image by author)</figcaption></figure><p>Common basis functions are B-splines, Wavelets or the Fourier basis. The more basis functions we use, the more smoothing we induce. This can be wanted to reduce noise. In the plot above, I used 20 B-splines to estimate the underlying function to my data.</p><p>Now you learned what functional data is, and how we can estimate the underling functions from our discrete measurements. You are some kind of expert now.</p><h3>Functional Principal Component Analysis</h3><p>The Big Brother of principal component analysis.</p><p>There is a great amount of techniques to analyze functional data. Many of which have a non-functional counterpart, you likely already used. FPCA is based on principal component analysis, a famous dimension reduction technique. To understand FPCA we should at least speak briefly about PCA.</p><h4>Principal Component Analysis</h4><p>The small Brother of functional Principal Component Analysis.</p><p>PCA tackles a common problem within data analysis. Often times we have to reduce the dimensionality of huge datasets. This is quite problematic, as each dimension stores information which we would lose if we would neglect them. This said, one needs a measure of information while reducing dimensionality. In case of PCA this measure is the variation within our Data. Where there is variation, there is also Information.</p><p>PCA finds the so called principal components (vectors), which maximize the variance of the data along their direction. Each principal component explains a portion of the total variance in the data. They build an orthonormal basis, which means each datapoint is a linear combination of our principal components. Now we can reduce the dimensionality of our data by just using a subset of PC’s to represent our datapoints. For example, we would choose the minimal amount of PC’s that their summed variance exceeds 95%. This way we reduce the datasets dimension but still keep most information preserved.</p><p>If you are not familiar with PCA, I encourage you to read this article to get a better feeling for the technique.</p><p><a href="https://towardsdatascience.com/a-one-stop-shop-for-principal-component-analysis-5582fb7e0a9c">A One-Stop Shop for Principal Component Analysis</a></p><h4>The real Deal</h4><p>FPCA essentially does the exact same thing as PCA, but with some small differences. With PCA, we deal with vectors, while in FPCA we deal with functions. This means our Principal components are also functions, or curves. In the following we call them functional Principal Components (fPC’s). Now how do we find these fPC’s?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/590/1*T9HEifpptR-JosG3LRGQxQ.png" /></figure><p>We have n curves given, and find the first fPC by maximizing the variance over the first fPC-scores. We constraind the first fPC to one, as we could endlessly maximize by just increasing the first fPC. This way we can find a definitive answer to the maximization. The first fPC is the major source of variation in our data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/588/1*-jwJP7DWFfmmS55eh89ShQ.png" /></figure><p>Now the same process as for the first fPC applies to the second one (and to all following). Only this time we have an additional constraint. That is, that the second fPC is orthogonal to the first. In fact, all fPC’s have to be orthogonal to one another. Now each curve can be represented as a linear combination of the fPC’s. The fPC score tells us to what extent a curve does consist of its respective functional principal component.</p><p>Now you also know the theorie behind the functional principal components, but how does one apply this technique?</p><h3>an Examplary use Case</h3><p>and a quite morbide one too.</p><p>FPCA can be used in an exploratory fashion to gain a deeper view into your data. Of this I now want to give you an example. The data we want to analyze is the logarithmic mortality-rate of French men for the last 200 years [2].</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*opZ_3uyM-2VXsl-M7XwLfg.png" /><figcaption>(Image by author)</figcaption></figure><p>First we estimate the underlying functions to our data. This we do, using B-spline basis expansion, as explained earlier. This additionally induces smoothing, which is great as we reduce noise.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*7ejHTk5SqUq3ozqaTR2-fQ.png" /><figcaption>(Image by author)</figcaption></figure><p>Now we run functional principal component analysis and look at the first two functional principal components. These two explain about 97% of the variation in our data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*Uu0bOPGjbHhequoMPDP43g.png" /><figcaption>(Image by author)</figcaption></figure><p>The interpretation of these functional principal components can be quite hard, as there might not be an obvious counterpart in the data. In our case the interpretation is luckily quite intuitive.</p><p>The first fPC seems to be the variation around the mean function of our data. This variation decreases over time. One could also say, the older we get, the more certain our death becomes. This fPC explains 94% of the variation in our data.</p><p>The second fPC seems to stand in a relation with ages 20 – 40. It hints to cases in our data, where the mortality rate of this group varies greatly from the other age-groups. What immediately comes to mind, are the two great wars that caused the unnecessary death of so many young men.</p><p>If you remember when we spoke about how we can find the functional principal components? Back then we learned that each curve in our data can be expressed as a linear combination of the fPC’s, where each fPC score determined to what extent a curve is explained by which component. What we can do now is to reduce each curve to a two-dimensional point, consisting of the two first fPC scores.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/640/1*jsdzhKoNWILgvQ8OWGOpTQ.png" /><figcaption>(Image by author)</figcaption></figure><p>Now this is interesting. By the color-coding we can see that the curves of the war years are very much explained by the second fPC. This is good news as our interpretation was correct. We also can see very clearly that there is a great shift in mortality around 1950. This was not so clear in the original data. Not only did we gain an insight into our data, we also reduced its (high) dimension without loosing much information. We now are able to further work with this representation and apply conventional clustering algorithms.</p><p>Finally I want to mention, that I took inspiration for this analysis from [2]. If you are interested into a more in depth explanation and exemplary use of FPCA I encourage you to look into it.</p><p>Also in [3] you find the documentation for the scikit-fda python package. It provides many easy to understand examples for multiple functional analysis tools.</p><p>[1] <em>Human Mortality Database</em>. University of California, Berkeley (USA), and Max Planck Institute for Demographic Research (Germany). Available at <a href="http://www.mortality.org/">www.mortality.org</a> or <a href="http://www.humanmortality.de/">www.humanmortality.de</a> (data downloaded on [01.06.2021]).</p><p>[2] Shang, H.. “A survey of functional principal component analysis.” <em>AStA Advances in Statistical Analysis</em> 98 (2014): 121–142.</p><p><a href="https://fda.readthedocs.io/en/latest/auto_examples/index.html">[3] https://fda.readthedocs.io/en/latest/auto_examples/index.html</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91d21261ab7f" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/functional-principal-component-analysis-and-functional-data-91d21261ab7f">Functional Principal Component Analysis and Functional Data</a> was originally published in <a href="https://medium.com/data-science">TDS Archive</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>