<?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 Rahul Bohare on Medium]]></title>
        <description><![CDATA[Stories by Rahul Bohare on Medium]]></description>
        <link>https://medium.com/@rahulbohare?source=rss-410aff73a447------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/proxy/1*TGH72Nnw24QL3iV9IOm4VA.png</url>
            <title>Stories by Rahul Bohare on Medium</title>
            <link>https://medium.com/@rahulbohare?source=rss-410aff73a447------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 01:10:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rahulbohare/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[Parameter Inference — Maximum Aposteriori]]></title>
            <link>https://medium.com/data-science/parameter-inference-maximum-aposteriori-estimate-49f3cd98267a?source=rss-410aff73a447------2</link>
            <guid isPermaLink="false">https://medium.com/p/49f3cd98267a</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Rahul Bohare]]></dc:creator>
            <pubDate>Thu, 06 Apr 2017 22:51:18 GMT</pubDate>
            <atom:updated>2017-04-07T15:29:58.833Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*0LpRQhApzpL4xh5ZcVPwfA.jpeg" /><figcaption>I dare you to not laugh at this comic after going through the post. :D</figcaption></figure><p>In the <a href="https://medium.com/towards-data-science/parameter-inference-maximum-likelihood-2382ef895408">previous post</a>, we discussed the motivation behind Maximum Likelihood Estimate and how to calculate it. We also learned a few tricks about calculating the log likelihood of a function by citing the application of monotonic functions, and how they make the entire process of estimating the critical points of a function much easier as they preserve those critical points.</p><p>Towards the end of the MLE post, I tried motivating the reasoning behind going for MAP (Maximum Aposteriori) by asking a simple question:</p><blockquote>What if the sequence looked like following:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/189/1*TFDkfzT6GM_ZCMd9-SKVoQ.png" /><figcaption>Img. 1: A sequence of two Heads</figcaption></figure><blockquote>What do you think the probability of the third flip being <em>Tails </em>is?</blockquote><p>Clearly, in this case,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/112/1*3hZi9Emh8DihIi3ITXiQDw.png" /><figcaption>Img. 2</figcaption></figure><p>Why? Put the #tails (0) and #heads (2) in the equation of <em>theta_MLE</em>,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/195/1*LEmKYhQzPSbppID40IIkoA.png" /><figcaption>Img. 3</figcaption></figure><p>and we arrive at the result. This result tells us that the probability of next flip being <em>Tails </em>is 0 (i.e., it predicts that no flip is ever gonna turn up <em>Tails =&gt; </em>the coin is always going to show <em>Heads</em>), and it is glaringly obvious that this is not the case (barring the extreme case where the coin is heavily loaded). Now, this poses a big problem in the Parameter Estimation process because it does not give us the accurate probability of the next flip. We know that even a fair coin has a 25% chance of showing two <em>Heads</em> in a row (0.5 x 0.5= 0.25). So, it’s not that unlikely that the coin might be fair.</p><h3>The Posterior</h3><p>Although we know that MLE is a strong tool in Machine Learning but it does not come without it’s flaws (as we just saw), and these flaws occur when we have a limited amount of data available. The problem with MLE is that it is a <strong>point estimate, </strong>i.e., we are allowed to calculate the MLE at <em>one particular value</em> and this leads to <strong>overfitting</strong> (For those who have not heard of the term before, I’d refer you to <a href="https://www.quora.com/What-is-an-intuitive-explanation-of-overfitting">this</a> answer on Quora). Because it is a point estimate, it’s overfitting to the data (2 <em>Heads</em> in a row) and it’s not taking into account the possibility that the coin might still be fair (or might be only slightly biased towards <em>Heads</em>). The obvious question: <strong>How do we counteract this problem?</strong></p><p>Typically, we have <strong>prior beliefs</strong> about the processes going on in the world that have nothing to do with math. Let’s take a simple example: Suppose you are betting in a game of “Guess the flip” against your friend. Now it could be that you might assume that your friend has rigged the coin slightly to be biased in their favor, maybe making it a bit loaded in favor of <em>Heads; </em>55% <em>Heads</em> and 45% <em>Tails</em> (Nobody is stupid to make it extremely biased towards a particular flip, as it would be fairly easy to detect). These assumptions you make about a random process are called as Priors. In technical terms:</p><blockquote>A <strong>prior probability distribution</strong>, often simply called the <a href="https://en.wikipedia.org/wiki/Prior_probability"><strong>prior</strong></a>, of an uncertain quantity is the probability distribution that would express one’s beliefs about this quantity before some evidence is taken into account.</blockquote><p>Is there any way to incorporate these prior beliefs into our model mathematically?</p><p>YES: We can make the parameter <em>theta</em> itself a random variable, and it also justifies the notation that we have been working with; P(F = f|<em>theta</em>) [Note how nicely this assumption works out considering this notation already implies that <em>theta</em> is a random variable].</p><p>Now we can have distributions over <em>theta</em>, and incorporate the notion that even in extreme cases (HH), the coin being fair might still be a possibility. And as we’ll see, this notion also helps us in preventing Overfitting.</p><p>For any <em>x</em>, we want to be able to express the distribution of our parameter <em>theta</em> after seeing data, and we do that by conditioning <em>theta</em> over the observed data sequence, like so:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/140/1*t6PYPLRpLVoiC8CKF8fJuQ.png" /><figcaption>Img. 4: Posterior notation</figcaption></figure><p>where D is a random variable that captures the observed sequence at hand i.e., our data. And now that <em>theta</em> is a random variable, it can take on specific scalar values <em>x</em>. Because we are talking about the coin flips, we know that the above equation only makes sense for <em>x </em>in [0,1] (Since <em>x </em>is a probability, it has to be between 0 and 1).</p><p>I realize that this is a lot to take in. So, let’s take a step back and try to understand what was going on in MLE and how it compares to our ongoing MAP estimation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PCcbDIUHjCGl0DlqD3RluA.jpeg" /><figcaption>Img. 5: MLE - Likelihood is the probability of data <strong>given</strong> the parameter, and we were maximizing this w.r.t. <em>theta.</em></figcaption></figure><p>And now we are interested in:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7gM2WmUtOmPCoS9GtJlStQ.jpeg" /><figcaption>Img. 6: MAP — Maximizing the probability of theta <strong>after </strong>we have observed our data.</figcaption></figure><p>It’s not completely obvious right now what the MAP term intuitively means, but it will be by the time we will be done with this post.</p><p>And<em> in general</em>,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KZr1zrhzEsKvyDbn3U7uMQ.jpeg" /><figcaption>Img. 7: MLE != MAP</figcaption></figure><p>We can apply the good old Bayes’ rule to make the MAP formulation a bit more demystifying:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*tF1zp93WolW8ZVOb5kbPig.png" /><figcaption>Img. 8: Bayes’ rule on MAP (Posterior)</figcaption></figure><p>The numerator consists of:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/144/1*uz19CUqaqmRLbVy2Ch9_DA.png" /><figcaption>Img. 9: Numerator I — Likelihood</figcaption></figure><p>We know this part from MLE, with the only difference being that it is now fixed with <em>theta</em> = <em>x. </em>It is called Likelihood.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/99/1*j4VPFNecLIVIIOmKfllg9g.png" /><figcaption>Img. 10: Numerator II — Prior</figcaption></figure><p>This is our prior belief in the value of <em>theta</em> before observing any data. It is called the <em>Prior</em> and it prevents Overfitting. A little motivation on Priors in general:</p><blockquote>In a lot of cases, we have reason to believe that some values for <em>theta </em>are more likely than others. For example, in our coin flip case, we’d expect that the value is somewhere around 0.5 and extreme values such as 0 or 1 are less likely. This is what is captured by Prior and it will prevent extreme results (Overfitting).</blockquote><p>The denominator p(D), called <em>Evidence</em>, is a normalizing constant, and is not so important in our case. Without the denominator, the expression on the right-hand side is no longer a <em>probability</em>, and thus will not range from 0 to 1. The “normalizing constant” allows us to get the probability for the occurrence of an event, rather than merely the relative likelihood of that event compared to another. Check out <a href="http://stats.stackexchange.com/questions/129666/why-normalizing-factor-is-required-in-bayes-theorem">this discussion on stackexchange</a>.</p><p>What we should take home from all this discussion is three terms:</p><ol><li>Prior</li><li>Likelihood, and</li><li>Posterior</li></ol><p>and that they are connected by Bayes’ rule. So, Prior is our belief in how <em>theta </em>looks like before we observed any data, and Posterior is our <em>updated </em>belief as to what <em>theta</em> looks like <em>after </em>we have observed some data.</p><p>Now we have established a link between likelihood (which we have been using in the last post) and posterior (which is of our interest now). And the link between these two is the <em>Prior </em>distribution, and Prior distribution is part of <em>our </em>model. So, it is us who get to choose the prior. <em>The point of the prior is that we have to choose it without looking at observations, </em>and this leaves room for (possibly subjective) model assumptions. There is no particular rule that prior needs to fulfill except that it needs to be a valid probability distribution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*dBqM-flB8ZAaFpg6Dxirzw.png" /><figcaption>Img. 11: Prior is just a probability distribution.</figcaption></figure><p>Let’s see a couple of examples of Priors:</p><ol><li>We assume that possibilities other than 0 (which was the MLE for HH sequence) exist. Now this prior is extremely <em>weak</em> in the sense that it does not give much information about what those possibilities actually are.</li><li>We can also assume that the parameter <em>theta </em>is most probably in the region between 0.4 and 0.5, which is around the true probability of 0.5 (despite the MLE solution telling us that it is 0). Since we are confining our assumption to a certain region, this is an example of a fairly <em>strong </em>prior.</li></ol><p>These subjective assumptions are also called <strong>Inductive Biases</strong>. <em>By introducing these subjective assumptions, we are biasing our analysis/model towards certain solutions.</em> It’s something we must be aware of while writing down a model.</p><h3>MAP Estimation</h3><p>The following graphs illustrate a few choices we have for the prior on <em>theta</em>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/665/1*0mY-XiN_KfiF-tC2bTRXIQ.png" /><figcaption>Img. 12: Prior choices (x-axis represents probability for theta. y-axis represents probability density)</figcaption></figure><p>The first graph shows a uniform distribution on all the possible parameters. It does not put any inductive bias on the model, and hence does not prefer any solutions for <em>theta </em>over others. In other words, this is our Maximum Likelihood Estimate. So, we can say that <strong>MLE is a special case of MAP when the prior is uniform</strong>.</p><p>The other three options put some inductive bias on <em>theta</em>. In particular, we can see that all of them are centered around 0.5 with different width (One cookie if you can deduce the decreasing order of the strictness the last three models assume on the prior. ;)). This means that all of the last three assume that the real solution is in a small interval around 0.5, with varying width of the intervals.</p><p>Okay, now we have some idea on how our prior should look like. Can we have some more motivations behind the choice of our prior model? One possible motivation could be that we can choose a prior such that it eases the further computations (they don’t get very extensive). This is one of the driving factors for choosing the appropriate prior for our specific model (in our case: the coin flip).</p><p>Since prior is just another probability distribution, we’d like to choose this distribution in such a way that it makes our subsequent calculations easier. And it turns out that whenever we are looking for a prior for a parameter that directly corresponds to a probability (like in our case, <em>theta</em> corresponds to the probability of <em>Tails</em> showing up in a coin flip), there usually exists such priors which fit well.</p><p>In our case, this prior is going to be a <strong>Beta distribution</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/584/1*qbjwnDo86UYO1U6PmVQ4Cg.png" /><figcaption>Img. 13: <a href="http://mathinsight.org/probability_density_function_idea">pdf</a> of a beta distibution</figcaption></figure><p>Beta distribution can be understood as representing a <em>distribution</em> <em>of probabilities</em>- that is, it represents all the possible values of a probability when we don’t know what that probability is. For a more intuitive understanding, see <a href="http://stats.stackexchange.com/questions/47771/what-is-the-intuition-behind-beta-distribution">this</a>.</p><p>Okay, this looks very byzantine and disheartening at first glance, but stay with me here. Let’s look at it closely; we start to notice terms which we have already seen before:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/177/1*8Tn4isCOaJsmvld2JnKXQw.png" /><figcaption>Img. 14: We have seen an extremely similar form in MLE.</figcaption></figure><p>We have seen the component in Img. 14 in MLE, except that the #<em>Heads</em> and #<em>Tails </em>in the exponents have been replaced with a-1 and b-1.</p><p>Along with the <em>theta</em> term, we have normalizing constant, which has <a href="https://en.wikipedia.org/wiki/Gamma_function">Gamma functions</a>. A gamma function is nothing more than an extension of the factorial function, with it’s argument shifted down by 1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*4AvCzWcDTQYR23k_uiSMPg.png" /><figcaption>Img. 15: Gamma function</figcaption></figure><p>The special characteristic of a gamma function is that it allows us to evaluate the factorial at any real value (Gamma function of 1.5 is well defined, whereas 1.5! is not defined).</p><p>The fact that we have seen this before in parts is no coincidence. We’ve chosen a <em>Conjugate Prior</em>. Whenever we have a prior that has a similar functional form as the likelihood and they fit well together, we talk about so called <strong>Conjugate Priors, </strong>and the Beta distribution is a conjugate prior for the likelihood for our coin flip experiment. The interpretation is the following: Without seeing any data, we have a feeling about what the outcome of our coin flip experiment is going to be. In our experiment, if we were to do a+b-2 coin flips, then we can choose the prior such that a-1 of those flips would show up <em>Tails</em> and the remaining b-1 would show up <em>Heads.</em></p><p>So, if we would assume the coin to be unbiased, we’d choose a and b to be equal. And the more certain we are about this assumption, the higher we’d choose a and b.</p><p>The following graphs illustrate a few choices of a and b for our Beta distribution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*-cQlkPEkiDlpyXSSWE3WdQ.png" /><figcaption>Img. 16: Four different Beta distributions (x-axis represents the probability for theta. y-axis represents density)</figcaption></figure><p>If you wanna play around with different Beta distributions, check this iPython notebook <a href="https://github.com/dovahkiin2/hello-world/blob/master/Beta%20distributions.ipynb">here</a>.</p><p>Interpretations of four graphs:</p><p>a. Choosing a and b to be 1 (equal) signifies that we have no assumptions about our experiment whatsoever. This is an important feature of Beta distribution: it generalizes to a uniform distribution when a = b = 1.</p><p>b. Choosing a &lt; b represents that we are less certain about <em>#Tails</em> than the <em>#Heads</em>. The graph clearly illustrates this by showing that the probability of <em>Tails </em>is more likely to be less than 0.5.</p><p>c. We are twice as certain about the flip being <em>Tails </em>than being <em>Heads. </em>As we can see from the graph, the probability of the flip being <em>Tails </em>is biased to be greater than 0.5.</p><p>d. Choosing a and b to be non-integers favors extreme solutions. Choice of non-integers for a and b unfortunately does not have any viable physical interpretation, but it gives us a lot of flexibility in modeling the prior distribution.</p><p>In a sense, the more certain we are about our prior assumption, the higher we can choose a &amp; b to be, as it is visible from the ‘b’ and ‘c’ graphs in Img. 16.</p><p>Now that we have reasoned through various arguments that Beta distribution is a suitable prior for our coin flip experiment, let’s plug everything we know into the Bayes’ formula we used in Img. 8:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*tF1zp93WolW8ZVOb5kbPig.png" /><figcaption>Img. 17: Bayes formula for Posterior</figcaption></figure><p>We know:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*40U-okBfirrqPyrLN1wuGQ.png" /><figcaption>Img. 18: MLE part in our MAP solution</figcaption></figure><p>Now you might be thinking that the likelihood we derived <a href="https://medium.com/towards-data-science/parameter-inference-maximum-likelihood-2382ef895408">before</a> had <em>theta</em> in it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*a5E6oxJNN2SF87w-F1tZew.png" /><figcaption>Img. 19 : Likelihood</figcaption></figure><p>The reason we now have <em>x </em>instead of <em>theta</em> is because we have assumed that <em>theta </em>in itself is a random variable and can take on a specific value <em>x.</em></p><p>Since we have already decided that the prior is a Beta distribution, it takes on the following form:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*RRYI9hgpc0IK6KCZeyaRdg.png" /><figcaption>Img. 20: Prior</figcaption></figure><p>Plugging these values in the Bayes’ rule:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/711/1*y7CMK4IBrD4L3NUj6ejYEw.png" /><figcaption>Img. 21: MAP formulation</figcaption></figure><p>The second statement introduces a proportionality sign by leaving out p(D) as well as the normalizing constant of the Beta distribution as both of them are constants w.r.t. <em>x. </em>(Also, leaving out constants does not change the position of the maximum, only it’s value changes.)</p><p>Consider the second statement in the above image. We can see why Beta distribution or Conjugate priors in general are powerful because this term actually looks like the likelihood,except that it has these correcting terms a-1 and b-1. So no matter how extreme |T| and |H| are (like in the case where we only flipped the coin twice), we have these correcting terms a &amp; b.</p><p>What we are essentially doing here is pulling the result away from the extreme marginal results like we got in the maximum likelihood case with too little data. And the reason why conjugate priors are such an excellent choice for priors is because they have exactly this effect.</p><p>Okay, now we are left with the following term:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/435/1*BV23xRtCQiKMyJtl5ggP8A.png" /><figcaption>Img. 22: MAP with proportionality</figcaption></figure><p>How do we find the multiplicative constant that turns the proportionality sign into an equality sign?</p><blockquote>Let’s take a detour to figure out how to come up with the solutions of specific integrals which are not solvable (or, at least, very difficult to solve) by conventional methods:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i4fvDAJlmXdiBP_WfW_3MQ.jpeg" /><figcaption>Img. 23: A not-so-easy integral</figcaption></figure><blockquote>Do you think you can solve this integral on paper analytically? I am not majoring in Maths but to me, the answer is Yes and No. Yes, you can, but it will take a considerable amount of time to arrive at the result by conventional calculus rules, assuming you somehow are able to come up with the solution. No, well, because of the similar reasoning that it takes too long.</blockquote><blockquote>Now if you know your probability distributions very well, you would know that the following integral is:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*7xB_4fpxHpoBo4Mn6c-BYw.jpeg" /><figcaption>Img. 24: Standard gaussian pdf</figcaption></figure><blockquote>a pdf for a standard gaussian with 0 mean &amp; unit variance i.e., X ~ N(0,1), and it equals 1. If you wanna brush up on Gaussians, I think the w<a href="https://en.wikipedia.org/wiki/Normal_distribution">ikipedia article</a> is pretty solid.</blockquote><blockquote>If the above integral equals 1, it is just a matter of rearranging terms by multiplying both sides by sq.rt(2*pi) to come up with the answer to the actual integral we were talking about (Img. 23)., and we see that:</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VHthA7La9usCk0DYV8preQ.jpeg" /><figcaption>Img. 25 : Answer to the not-so-easy integral</figcaption></figure><blockquote>Hence, in a sense, we reverse-engineered our way to arrive at the solution to a considerably difficult integral.</blockquote><p>Now that we have a pretty handy trick under our belt, let’s see if we can apply it to find out the proportionality constant for our MAP estimate.</p><p>We know that our prior distribution sums up to 1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/186/1*YW66YDwLzWEZBxBVncobkw.png" /><figcaption>Img. 26: The only constraint on prior</figcaption></figure><p>AND the RHS in Img. 22 expression for MAP is proportional to a Beta pdf, which integrates to 1. Notice the uncanny similarity to our cool trick?</p><p>Consequently, by reverse-engineering, the posterior must also be Beta distributed and the only constant that works here is the normalizing constant of the respective Beta distribution:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/245/1*-j5v67KIy8F4b6SguGvY2g.png" /><figcaption>Img. 27: Constant of Proportionality for our MAP</figcaption></figure><p>There is no other constant that lets the RHS of our MAP estimate integrate to 1. But since it <em>has to</em> integrate to 1, this is the only working constant.</p><p>Whenever we are supposed to solve a difficult integral, we examine it closely and try to find if it looks like a pdf. And if it does, we can easily reverse-engineer the normalizing constant of this pdf and can then easily solve the integral.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*oyRIVHU1lRLM-GAefzRzgQ.png" /><figcaption>Img. 28: Note on the reverse engineering trick</figcaption></figure><p>An immediate and very nice consequence of this reverse-engineering trick is that we can easily determine the distribution of our posterior. This allows us to know that our posterior needs to be a Beta distribution and we also know the parameters:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/452/1*UDq1eMDp5otBtSDE77vG_g.png" /><figcaption>Img. 29: Posterior — Beta distribution</figcaption></figure><p>Now we can find the maximum of our parameter <em>theta</em> just like we did in the MLE <a href="https://medium.com/towards-data-science/parameter-inference-maximum-likelihood-2382ef895408">post</a> (I am skipping the actual calculation; it’s a trivial application of log to the equation in Img. 21 to find out the maximum), and we arrive at the following result:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/356/1*2P2bhiJ-7ZLrRyEB1ZMSNA.png" /><figcaption>Img. 30: MAP Solution</figcaption></figure><p>Comparing this MAP estimate with the ML estimate (|T|/|H|+|T|), we see they are very similar. The term |T|/|H|+|T| pops up again in MAP estimate, except that it is corrected by our prior belief.</p><p><em>Under our prior belief and after seeing the (i.i.d.) data, theta_MAP is the best guess for theta.</em></p><p><strong>It is called the Maximum Aposteriori Estimate (MAP).</strong></p><p>Notice the most important thing here: The Posterior works <em>very </em>intuitively. If we have very little data (like in our second experiment where we had only 2 coin flips, both of them being <em>Heads</em>), the effect of the prior is much stronger. On the other hand, for a fixed a &amp; b, if we perform sufficiently many coin flips (for instance, a million), then the effect of a &amp; b is almost negligible and we get very close to the MLE. This is very intuitive because in the low data regime, the prior prevents overfitting whereas if we have a lot of reliable information from the random process, we don’t really need the prior information anymore. We can get all of it from the data itself. In other words, MLE dominates when we are swimming in data.</p><p>Is this the end of the process? We have already incorporated our assumptions about the way the world works, the way random processes unfold. What more is left to accomplish? Now we can just sit back and watch the LOTR trilogy.</p><p>Or can we? As it turns out, when we incorporated our prior beliefs into the model, we implicitly favored some solutions more than others (by assuming a beta distribution over the coin flip process, we biased the MAP estimate towards a particular solution; a form which looks like Beta pdf). What about all the other priors which can also affect a process, albeit in a very subtle way? Is there some way we can incorporate them into our model too? As you already know, the answer is YES, and we will discuss it in depth in the next post when we talk about Fully Bayesian Analysis of our model.</p><p>I realize that this post was not easy to follow at times, there was a lot of maths involved. I hope I made it a little bit easier and intuitive for you to understand the process of MAP Estimation. If you find any specific part too esoteric, feel free to leave a comment, I will attend to it as soon as I can.</p><p><strong>Resource</strong> : The ML course taught at my grad school, TU Munich. Feel free to watch the lectures <a href="https://www.youtube.com/channel/UCpyPuMAyBvERU8YMngGy11g">here</a>.</p><p>If you find this post interesting, please recommend and share it so that others can benefit from it as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=49f3cd98267a" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/parameter-inference-maximum-aposteriori-estimate-49f3cd98267a">Parameter Inference — Maximum Aposteriori</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[Parameter Inference — Maximum Likelihood]]></title>
            <link>https://medium.com/data-science/parameter-inference-maximum-likelihood-2382ef895408?source=rss-410aff73a447------2</link>
            <guid isPermaLink="false">https://medium.com/p/2382ef895408</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[towards-data-science]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[Rahul Bohare]]></dc:creator>
            <pubDate>Mon, 03 Apr 2017 09:14:22 GMT</pubDate>
            <atom:updated>2017-04-06T22:52:21.638Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/468/1*ULb9lkajm38eGIfrtRX7ZQ.png" /><figcaption>The never ending debate of Frequentists and Bayesians. (Image source: <a href="https://xkcd.com/1132/">xkcd</a>)</figcaption></figure><p>This post takes an in-depth tour in one of the most important concepts of theoretical Machine Learning, viz., Parameter Inference. I will try to focus on an intuitive understanding of the concept while embedding mathematical formulae as and when I feel the need for them. If you have ever taken a undergraduate/graduate level Machine Learning course in a university, you must have come across Parameter Inference. When I encountered this for the first time, I kept scratching my head for quite a while trying to grasp the concept of PI (not a well known acronym for Parameter Inference), and that’s why I felt the need to write a post try to make it easier for others to understand. I hope you take something valuable out of this post when we are done with it. Let’s begin.</p><p>PI can liberally be described as the process of determining the parameters which govern the dataset being generated from an experiment. For example, if we flip a coin ten times and get the following dataset,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/628/1*7n4g4m4X2t8cVxlZiEl-eA.png" /><figcaption>Img. 1: 10 flips of a coin</figcaption></figure><p>what is the parameter responsible for generating these ten flips? As it turns out, the process of parameter inference is not completely trivial and requires quite a bit of mathematical savvy to wrap our heads around. If you understand the basics of logarithms, calculus (differentiation to be precise) and basic probability, this post should not be mystical to understand. Anyway, let’s get down to the business. PI can be considered as a step-wise process having three major steps:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/503/1*Ldi4VHZW0t3HOHu445knfQ.jpeg" /><figcaption>Img. 2: Three steps to Parameter Inference.</figcaption></figure><p>We start at the lowest step and will try to reach the topmost one. Each successive step is slightly more convoluted than the preceding, but at the same time, it provides us with a more robust model to describe the data. This post will tackle the lowest step, <em>Maximum Likelihood Estimation</em> in detail, and the follow-up posts will deal with the other two steps. <em>(A side tip: Use pen and paper to easily follow the terms and formulae as Medium doesn’t support Math symbols yet)</em>. Okay, So what is MLE?</p><h3>Maximum Likelihood Estimation</h3><p>As the picture says, the entire process of MLE revolves around determining the parameters which maximizes the probability of the data. Going back to the coin toss example, what do you think the probability of the 11th flip being <em>Tails </em>is? There are two logical answers:</p><ol><li>If you say 0.5, that’s a reasonable answer as the flips are independent of each other and the next flip being <em>Tails </em>has a 1/2 chance, i.e., 0.5.</li><li>The other answer could be 0.3. The rationale behind this answer would be that we can expect the coin flips to continue the way they have occurred until now (until the 10th flip).</li></ol><p>I am not gonna tell you the correct answer just yet. Let’s work together to find out which one is correct. Okay, so we need to find out <em>P_11</em>(<em>F_11</em>= <em>Tails</em>), where P_11 is the probability of 11th flip and F_11 is the 11th flip. This gives rise to the general case: <em>i</em>th flip being <em>Tails:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/197/1*Xi7G1x760IshTCU-XOW6Eg.png" /><figcaption>Img. 3</figcaption></figure><p>where <em>F_i </em>denotes <em>i</em>th flip and <em>theta_i </em>being the parameter governing the <em>i</em>th flip. To denote that the probability distribution depends on <em>theta_i</em>, we can write:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/183/1*2J8lTJcHrHUbK-MYqjw45g.png" /><figcaption>Img. 4</figcaption></figure><p>Do you see the problem here? We have the data that depends on parameters <em>theta_1 </em>to <em>theta_10 </em>(i = 1 to 10)<em>. </em>And that poses a problem in that how can we extrapolate it to <em>theta_11</em>? For the time being, let’s stick to what we have, i.e., <em>theta_1 </em>to <em>theta_10.</em></p><p>All the randomness of a sequence of flips is governed (modeled) by the parameters <em>theta_1 </em>to <em>theta_10:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*kQx4YgaFA0FQUCh5F6Uceg.png" /><figcaption>Img. 5</figcaption></figure><p>What do we currently know about <em>theta_1 .. theta_10</em>? And are they, in some way, connected to <em>theta_11</em>? At first glance, there seems to be no connection. It is now that we can start the process of MLE: we need to find <em>theta_i’s </em>such that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/527/1*kQx4YgaFA0FQUCh5F6Uceg.png" /><figcaption>Img. 6</figcaption></figure><p>is as high as possible. This is the principle behind MLE:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/781/1*d5CXJKGkh1r0ywYa7vwJ4Q.png" /><figcaption>Img. 7</figcaption></figure><p>MLE looks at the probability of data (the so called <em>Likelihood; </em>Img. 5 &amp; 6) and it tries to find those parameters <em>theta_1 </em>through <em>theta_10 </em>that maximize the likelihood/probability of this sequence. To reiterate one last time, we want to choose those parameters under which our observations become most likely. That’s why the process is called MLE.</p><p>Now let’s try to actually model the probability depicted in Img. 5 &amp; 6. We need to make two critical assumptions in order to be able to work out the ML estimate of the data:</p><p>I. The coin flips do not affect each other, i.e., they are i<em>ndependent </em>(the outcome of first flip does not affect the outcome of the second flip, and so on)<em>:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/702/1*GsOToZE0CzwQ8gBrf0lqsg.png" /><figcaption>Img. 8: The independence assumption allows us to simplify the complex likelihood term into ten simpler factors.</figcaption></figure><p>The third statement in Img. 8 is just a short-hand notation describing the product of the ten terms from the second statement.</p><p>The first assumption allows us to simplify the likelihood term considerably but notice that there is still <em>theta_i </em>present in the shorthand notation. What it means that we still don’t have <em>theta_11</em> in the equation.</p><p>There is another assumption that can further unravel the equation. It arises from the fact that the coin (the experiment setup, in general) does not change significantly:</p><p>II. The flips are quantitatively same, i.e., they are <em>identically distributed:</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/419/1*6jp2fsqHM84SZcBAQSiq6A.png" /><figcaption>Img. 9: Since the flips are taking place under similar circumstances, we can assume that the parameter governing the flips is one and same.</figcaption></figure><p>It is the second assumption of the flips being identically distributed that allows us to drop the subscript <em>i </em>from <em>theta</em>. This means that all of the 10 flips we observed are essentially governed by the same parameter <em>theta; </em>instead of having ten parameters governing ten different flips, we now have just one parameter governing the entire sequence of coin flips, and that includes the 11th flip as well. In a sense, we are connecting the first 10 coin flips to the 11th coin flip. As we’re soon going to see, this is going to be the key for inference.</p><p>NOTE: The two assumptions we made are used so often in Machine Learning that they have a special name together as an entity, <strong>i.i.d. assumption</strong>:</p><p><strong>In total, the 10 flips are independent and identically distributed.</strong></p><p>This allows us to explicitly write down the likelihood that we are trying to optimize. Remember that <em>theta </em>was defined as the probability of the flip showing up <em>Tails</em>; the probability of our sequence w.r.t. <em>theta</em> can now be formulated as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/796/1*vEQyqeA7o7LrBLREjwt2eA.png" /><figcaption>Img. 10: First term is the probability of <em>Heads, second for Tails, third and fourth for Heads, fifth for Tails and so on. Note that this formula corresponds to the sequence of our coin flip.</em></figcaption></figure><p>So, by this very broad and very intuitive assumption i.i.d., we simplified our likelihood function to a fairly simple polynomial; to a point where we can start optimizing the function for the parameter <em>theta.</em></p><p>Under our model assumptions:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/537/1*a5E6oxJNN2SF87w-F1tZew.png" /><figcaption>Img. 11</figcaption></figure><p>The above simplified polynomial expression can be interpreted as a function of <em>theta</em> i.e., <em>f(theta)</em>. Now we want to find out the maxima (maximum likelihood) of this function. Any ideas on how to proceed?</p><p>That’s right! It’s all basic high school math from here. We take the derivative <em>df/d(theta)</em>, set it to zero, and solve for <em>theta. </em>And then verify the <a href="http://mathinsight.org/critical_points_monotone_increase_decrease_refresher">critical points</a> (points where slope of a function is zero: maxima, minima and saddle points. In this case, we are only concerned with maxima) by inserting them into the second derivative of <em>f(theta)</em>.</p><p>In principle, this is fairly straightforward. Except one caveat: the second derivative of <em>f(theta) </em>is already ugly since we will need to apply the <a href="https://www.math.ucdavis.edu/~kouba/CalcOneDIRECTORY/productruledirectory/ProductRule.html">product rule</a> <em>twice</em> to get there. It is doable, but it requires a lot of technical humdrum to get there. Is there any way we can simplify our computations?</p><p>The beauty of mathematics is that is that it provides us with numerous pathways to arrive at a particular solution. Some of them being magnitudes of times easier than others. We are gonna apply one such simpler pathway to optimize our likelihood function:</p><blockquote><em>Let’s take a little detour into high school calculus and analyze monotonic functions (If you feel comfortable with this concept already, feel free to continue down to the end of this section). We already know how to find out maxima or minima of a function and that the actual maxima and minima values are called </em>Critical points <em>of the function</em>. <em>There is a rule in mathematics that</em> if we apply a monotonic function to another function which we are optimizing, the application of monotonic function will preserve the critical points of the original function <em>(The </em><a href="https://en.wikipedia.org/wiki/Monotonic_function"><em>wikipedia article</em></a><em> is an excellent source to learn more about monotonic functions).</em></blockquote><blockquote><em>If x1 &lt; x2 =&gt; f(x1) &lt; f(x2) : this is a </em>monotonically increasing function<em>.</em></blockquote><blockquote><em>If x1 &lt; x2 =&gt; f(x1) &gt; f(x2) : this is a </em>monotonically decreasing function<em>.</em></blockquote><blockquote><a href="http://catalog.flatworldknowledge.com/bookhub/reader/4372?e=fwk-redden-ch07_s03"><em>Log function</em></a><em> is an example of a monotonically increasing function:</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ehJ78FmFQJH0Lp-RxS6v5w.png" /><figcaption>Img 12: A monotonically increasing function — log(x)</figcaption></figure><blockquote><em>Hence, we can conclude that</em> log f(theta)<em> has the same maxima as</em> f(theta).</blockquote><p>Therefore, if we apply log to our likelihood function, we will essentially get the same maxima as we would have gotten had we directly optimized it.</p><p>So we want to find out:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*B3P2xKu7fZBIm-qMVXhpZQ.jpeg" /><figcaption>Img. 13: arg max f(theta)</figcaption></figure><p><a href="http://math.stackexchange.com/questions/312012/what-is-the-difference-between-arg-max-and-max">Arg max</a> means that we want to know the <em>value of</em> <em>theta</em> where this function is maximized rather than the <em>maximum value of the function itself</em>. This means that we are <strong>not</strong> actually concerned with the actual maximum value of the function. Rather, we are interested in the value for <em>theta </em>where the function has the maximum value (Let that sink in for a moment before proceeding).</p><p>Taking the log of this function:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YXjdMk4r-pW3rHH6yGY-Wg.jpeg" /><figcaption>Img. 13: log arg max f(theta)</figcaption></figure><p>We denote this function by <em>g(theta)</em> : log likelihood.</p><p>Taking the derivative of <em>g(theta),</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wpiKmSTX-FimvVUl0rfA9A.jpeg" /><figcaption>Img. 14: derivative of g(theta)</figcaption></figure><p>where |T| are the number of tails (3 in our example), and |H| are the number of heads (7 in our example). I introduced the T and H to make the solution generalizable.</p><p>Setting the value of <em>g’(theta) </em>equal to zero (to find the critical value for <em>theta</em>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*etcdQfUP7x6B81iMVcSoZg.jpeg" /><figcaption>Img. 15: Critical value of theta — I</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i3Tl5NHvJ6ODl8YeTnZB6g.jpeg" /><figcaption>Img. 16: Critical value of theta — II</figcaption></figure><p>Therefore, Maximum Likelihood Estimation (MLE) for any coin sequence:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/195/1*LEmKYhQzPSbppID40IIkoA.png" /><figcaption>Img. 17: Theta MLE</figcaption></figure><p>We have arrived at our MLE estimate for the parameter <em>theta</em> which governs our coin flip dataset. Going back to the original question, what is the probability of the 11th flip being <em>Tails</em>?</p><p>Put |T| = 3 and |H| = 7, we get the answer as 0.3 . This justifies 30% as a reasonable answer to our initial question.</p><p>Now we need to substitute this critical value of <em>theta</em> in the second derivative to verify that it is indeed the maximum. I am skipping this verification here for brevity’s sake. But please go ahead and convince yourself that this is indeed the maximum value.</p><p>This maximum is called the <em>MLE for</em> <em>theta. </em>This particular <em>theta</em> is the one that makes our observed sequence most likely.</p><p>Intuitively, this 30% value is also justified by the fact that we expect the coin flips to continue they way they started. So, we have found that the MLE explains our intuition when we look at data and that’s very nice.</p><h3>MLE’s shortcoming?</h3><p>Clearly, finding MLE is not the end of Parameter Estimation as we have already seen in the staircase figure. We are still left with <em>Maximum Aposteriori Estimate</em> and <em>Fully Bayesian Analysis. </em>So what motivates not stopping at MLE and be done with the process? Can you think of a reason?</p><p>What if the sequence looked like following:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/189/1*TFDkfzT6GM_ZCMd9-SKVoQ.png" /><figcaption>Img. 18: A sequence of two Heads</figcaption></figure><p>What do you think the probability of the third flip being <em>Tails </em>is?</p><p>In the upcoming <a href="https://medium.com/@rahulbohare/parameter-inference-maximum-aposteriori-estimate-49f3cd98267a">posts</a>, we’ll explore the shortcomings of MLE, the intuitive rationale behind finding out MAP (<em>Maximum Aposteriori Estimate</em>) and <em>Fully Bayesian Analysis</em> and will also build up a few key concepts in ML, viz., Conjugate priors, Inductive Priors and a technique which allows us to calculate unsolvable integrals.</p><p>If you have any concept(s) in mind which doesn’t make intuitive sense to you and would like to see a similar post(s) for it, let me know in the comments and I’ll try to come up with them.</p><h4>Resource:</h4><ol><li>The brilliant ML course taught at my grad school, TU Munich. You can watch all the lectures at this YouTube <a href="https://www.youtube.com/channel/UCpyPuMAyBvERU8YMngGy11g">channel</a>.</li></ol><p>If you liked the post, feel free to recommend and share it so that others can benefit from it as well.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2382ef895408" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/parameter-inference-maximum-likelihood-2382ef895408">Parameter Inference — Maximum Likelihood</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[NeuraLink — Ushering humanity to transcendence]]></title>
            <link>https://medium.com/@rahulbohare/neuralink-ushering-humanity-to-transcendence-db628ba0813f?source=rss-410aff73a447------2</link>
            <guid isPermaLink="false">https://medium.com/p/db628ba0813f</guid>
            <category><![CDATA[science]]></category>
            <category><![CDATA[elon-musk]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[brain]]></category>
            <dc:creator><![CDATA[Rahul Bohare]]></dc:creator>
            <pubDate>Sat, 01 Apr 2017 22:46:45 GMT</pubDate>
            <atom:updated>2017-04-02T02:40:20.812Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dvZuBQKB_h3kIOAuBuRO7A.jpeg" /><figcaption>Soon, very soon.. (Image Source: <a href="https://pixabay.com/en/mechanical-brain-man-machine-2033446/">Pixabay</a>)</figcaption></figure><p>Chances are, if you are reading this, you know the name <strong>Elon Musk</strong> very well. Yes, the same guy who came up with the ingenious idea of electronic payments in the form of PayPal, made the dream of electric cars a reality with Tesla, started installing all our homes with efficient <em>and</em> fancy solar panels and launched first ever reusable rocket and is looking to conquer Mars with SpaceX. But apparently, despite doing all of this for Earth and humanity, he needs more on his hands to be able to sleep less at night, because well, let’s face it, he is a cyborg. Now he’s come up with the ingenious idea of connecting our brains with computers, with the eventual purpose being to enable humanity to keep up with the pace of AI.</p><p>At first glance, the idea sounds as if it is brought to reality straight from science fiction, but if you have ever followed the advent of Brain-Computer Interfaces, you would have recognized immediately that it is not an entirely novel idea. An excellent neuroscientist going by the name of Miguel Nicolelis first came up with BCIs and took the field by storm. For those interested in BCIs in general, his book <a href="https://www.amazon.com/Beyond-Boundaries-Neuroscience-Connecting-Machines/dp/1250002613/ref=sr_1_6?ie=UTF8&amp;qid=1491075453&amp;sr=8-6&amp;keywords=Beyond+Boundaries"><em>Beyond Boundaries</em></a> is a breath-taking read from prologue to the epilogue. The concept of BCIs is to use computer algorithms to transform the recorded EEG signals into commands. So if Elon’s idea is not exactly new, then how is it different from the classical BCIs? What does it promise? And most importantly, is it realizable in the foreseeable future? Let’s break it down.</p><h3>What in the world is NeuraLink actually?</h3><p>Let’s hear it from the man-of-the-hour <a href="https://youtu.be/wsixsRI-Sz4?t=56m30s">himself</a>:</p><blockquote>Just as we have a limbic system and the cortex on top of it, we can have a digital layer on top of the cortex which could work symbiotically with the lower layers. The fundamental limitation humans have is I/O. The rate at which we consume input is much higher than that we can produce output at (compare eyes and ears vs. mouth and hands). Merging symbiotically with the digital intelligence revolves around eliminating the I/O constraint. If you are able to establish a high-bandwith neural interface with your digital self effectively, you are no longer a house-cat (to a superior AI).</blockquote><p>Classical BCIs use an intrusive technology wherein your skull is cracked open, some electrode arrays are inserted into a direct connection with your brain, and EEG signals are used to simulate the targeted areas of brain. The most effective advancements this technology has led us to yet is the amelioration of neurodegenerative diseases like Epilepsy, Parkinson’s etc. What Elon is reaching for here is Proxima Centauri in a world where we have merely explored the neighboring continent. He visualizes a proxy to the famous trilogy <em>The Matrix </em>where humans are not only able to connect with their digital footprint and access any information about the universe instantly, but also internalize it at the same time.</p><p>What the technology promises is an ability to keep-up with the modern-day AI which is moving forward in leaps and bounds in the form of Deep Learning, Reinforcement Learning, or even classical Machine Learning. And as you have already read in Elon’s words, he wants this for humanity so that we don’t end up being a house-cat for a far more intelligent AI.</p><p>So much for the humane vision and only-Elon-like-commitment, now comes the million-dollar-question: Is NeuraLink feasible?</p><h3>Challenges for NeuraLink</h3><p>In order to start working towards the solution of a particular problem, there is next-to-impossible chance that you are gonna find the solution unless you understand the problem statement as well as you understand why 2 plus 2 equals 4. <strong>If the problem is worth solving, you <em>will need to internalize</em> it in your heart, mind and soul before you start thinking about the potential solution.</strong> SpaceX, Tesla and SolarCity became billion-dollar companies because we already knew the laws of orbital mechanics, electrodynamics, and physical sciences. The main challenge showing it’s fangs to NeuraLink is our extremely limited understanding of human brain and how the neurons interconnect and work the way they do. We need to first improve our understanding of brain processes and how to decode them.</p><p>Let’s assume for the sake of argument that NeuraLink is able to come up with a way of efficiently connecting brains and computers. There are still plenty of <a href="https://www.quora.com/What-do-neuroscientists-think-about-Elon-Musks-new-neural-lace-technology-Neuralink-startup/answer/Scott-Gosnell">challenges</a> to be overcome before we reach the stage Musk promised:</p><ul><li>We don’t have sufficiently advanced materials science to make an implant out of something that can stay in place for 20–50 years without decaying.</li><li>The implant should not disrupt the functioning of a healthy nervous system at any time.</li><li>It will have to make dynamic connections with the most complex system in the known universe on the fly and be able to accept technological upgrades to its own system.</li><li>It must simultaneously be impregnably secure from hacking without the consent of the person in whom it resides, but perfectly amenable to changes initiated by its user.</li></ul><p>So if there is a never-ending list of challenges being faced by NeuraLink, is all lost? The answer, as you all know, is a resounding <strong>NO. </strong>And why?</p><h3>Because hope is a good thing, maybe the best of things.</h3><p>Because it is precisely the consequences of far-reaching visions like these that humanity stands where it does. NeuraLink could be used to study how the processes in the mystical human brain work, how the neurons talk to each other the way they do, how the same complex and intricate neuronal interconnections which help a child learn to walk (not a trivial accomplishment at all, by the way) evolve into the neurons which land humanity on moon and potentially beyond.</p><p>We need such bold steps to put a spotlight on the fundamental research that is needed to accomplish larger goals. These visions are crucial in that they push the state-of-the-art boundaries and help scientists set and conquer long-term goals.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/550/1*2x4-3nPBIgG76J9aInXSyg.jpeg" /><figcaption><a href="http://aa-nplus1.tumblr.com/post/18075687043/detail-from-the-december-26-1965-edition-of-the">“Our New Age”</a> — Sunday comic strip Dec 26, 1965</figcaption></figure><p>We have already accomplished the first half of the prediction, but it will be magnitudes of times better if we can achieve the second half. And humanity is in safe hands enroute this journey as long as visionaries like Elon Musk are there to help us move forward.</p><h4>Further readings:</h4><ol><li><a href="https://www.quora.com/How-does-neural-lace-technology-work">How Neural Lace technology work?</a> (I highly recommend reading this Quora answer to gain an overview of the technology.)</li><li><a href="http://www.nature.com/nnano/journal/v10/n7/full/nnano.2015.115.html">Syringe-injectable Electron</a>ics</li><li><a href="http://www.nature.com/nmeth/journal/v13/n10/full/nmeth.3969.html">Stable long-term chronic brain mapping at the single-neuron level</a></li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=db628ba0813f" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Markov Chains— A take on Life]]></title>
            <link>https://medium.com/data-science/markov-chains-a-take-on-life-35614859c99c?source=rss-410aff73a447------2</link>
            <guid isPermaLink="false">https://medium.com/p/35614859c99c</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <category><![CDATA[reinforcement-learning]]></category>
            <category><![CDATA[life]]></category>
            <dc:creator><![CDATA[Rahul Bohare]]></dc:creator>
            <pubDate>Fri, 31 Mar 2017 17:55:43 GMT</pubDate>
            <atom:updated>2017-04-08T11:18:33.052Z</atom:updated>
            <content:encoded><![CDATA[<p><em>“The future is independent of the past given the present.”</em></p><p>A seemingly innocuous line embedded in slide #24 of just another lecture of just another class I was recently going through ended up being a complete revelation in terms of how we think and how we act (at least how I think and act). Before I get into it, let me give you a brief outline of how I stumbled upon this statement. I am also gonna be taking the liberty of providing a little peek into the workings of the model whose tagline could be potentially worth millions of dollars.</p><p>Recently I started watching <a href="https://www.youtube.com/playlist?list=PLHOg3HfW_teiYiq8yndRVwQ95LLPVUDJe">these</a> lectures on <a href="https://en.wikipedia.org/wiki/Reinforcement_learning">Reinforcement Learning</a> by David Silver, the lead programmer on the <a href="https://deepmind.com/research/alphago/">AlphaGo</a> team at <a href="https://deepmind.com/">Google DeepMind</a> (brilliant pedagogy for those interested in RL). For the uninitiated, <em>Reinforcement Learning is a sub-field of Machine Learning which deals with the process of decision making based on the rewards being received by the agent</em>. Allow me to make that clearer: Any goal that is achievable by the agent can be described by the maximization of the expected cumulative reward. In layman terms, if an agent wants to accomplish it’s goal, the reward associated with the actions it takes to reach that goal will be maximized.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*qhZwsXiweQcHYtvvb39xdg.png" /><figcaption>An example of RL for the robot agent. Image from <a href="https://www.safaribooksonline.com/library/view/hands-on-machine-learning/9781491962282/ch01.html">Safaribooksonline</a></figcaption></figure><p>As an example, consider the process of making a humanoid robot learn to walk; a positive reward might be constituted in the robot reaching the destination (or taking each step in the direction of the destination), whereas a negative reward can be associated with the action where the robot falls, or takes an action putting it further from it’s goal (This is a naive example, as the robot might actually end up getting a positive reward while moving away from the goal if it is exploring for better global pathways to reach the goal). It is with the combination of these positive and negative rewards that the robot eventually learns how to reach it’s potential destination.</p><p>Such processes can be easily visualized by the agent being in a certain state, and taking an action by considering the rewards for all immediately accessible future states and moving towards the state in which the reward is maximum (yes, it does sound a bit apocryphal, but believe me it isn’t). It is not very difficult to analyze that a greedy agent will take an action which corresponds to the highest possibly attainable reward from the present state.</p><p>Markov Chains are the backbone of Reinforcement Learning in that they help build the concept of decision making in a very simplistic way; the entire sequence of the states an agent has been in can be boiled down to it’s current state, i.e., the next reachable state can be predicted by the current state of the agent, regardless of the historical sequence of states the agent has been in. The following picture illustrates the idea in a concise way:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*N2udQkkUFYGD8hb_WiosGg.png" /><figcaption>A simple Markov Model</figcaption></figure><p>The labels on the edges refer to the probabilities of moving to the next state from the current one. For example, if today is rainy, the probability that tomorrow will be snowy is 0.02, that it will be rainy is 0.8 and so on.</p><p>Another simple example explaining Markov Chains can be illustrated as: Consider you are visiting a archipelago, with bridges connecting the islands. The bridges represent the probabilities of moving from one island to the next. The island you will be on tomorrow is determined from the island you are on today, with your previous positions having got nothing to do with the decision.</p><p>For mathematically oriented, a formulation of the Markov model can be described as:</p><p>A state <em>S_t+1</em> is <strong>Markov </strong>if and only if (forgive the absence of subscript) :</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/357/1*WqhNxSqZZAi0rn4P4fg99Q.png" /></figure><p>Explanation: The probability of moving to the next state given the entire sequence of states the agent has been in [RHS], is equal to the probability of moving to the next state given the present state [LHS]. In other words, since all of the information of the past states is already condensed in the agent’s current state, we can assume that the transition probability from the present state to the next one depends exclusively on the present state.</p><p>This can also be formulated as:</p><p>“<em>The future is independent of the past given the present.</em>”</p><p>It was this line in the slides of the first lecture where I realized how beautifully this statement applies not only to Markov Models but to all of our lives as well. The decisions that shape our future depend solely on the choices we make given our current state-of-mind; all of our past experiences are implicitly incorporated in our current state, in that they led us to where we are today.</p><p>Regretting over the past choices is not going to change anything in the larger scheme of how things are gonna unfold in the universe, the lamenting will only take its toll on us and will blur the decision making process for our future. So, let’s try and let go of the past by making the best out of the state we are in at the moment.</p><p>Let’s emulate a rational agent in making optimal decisions by analyzing the rewards for all the possible actions given our current situation. What better AI than humans making rational decisions all the time, am I right! ;-)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=35614859c99c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/markov-chains-a-take-on-life-35614859c99c">Markov Chains— A take on Life</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[Would you mind, yes, you!]]></title>
            <link>https://medium.com/@rahulbohare/would-you-mind-yes-you-5655f01e00f8?source=rss-410aff73a447------2</link>
            <guid isPermaLink="false">https://medium.com/p/5655f01e00f8</guid>
            <category><![CDATA[life]]></category>
            <category><![CDATA[writing]]></category>
            <category><![CDATA[poetry]]></category>
            <dc:creator><![CDATA[Rahul Bohare]]></dc:creator>
            <pubDate>Thu, 25 Aug 2016 17:07:06 GMT</pubDate>
            <atom:updated>2016-08-25T17:07:06.754Z</atom:updated>
            <content:encoded><![CDATA[<p>Would you mind, yes, you!<br>Would you mind challenging the power of your creation,<br>The whimsical magic of your imagination..<br>Leading only to the wiles of exhilaration.</p><p>Or rather mind starvation of your own soul?</p><p>Or the deprivation that you hold?</p><p>The results of the shackles of your thoughts which were then raw..<br>Leading only to gripes from shambles of life’s aw.</p><p>Now, would you mind igniting the spark within you?<br>Would you mind if the universe starts to gush for you?<br>From the keys that you hold, only one fits to make your way through the blue..<br>It may or may not be the one which has helped you survive and not thrive as a way to you.</p><p>Would you mind reigniting the courage you once claimed to have possessed?</p><p>Would you mind unlocking the gridlock which could have stressed?</p><p>This is the place you often get trapped by the indigenous mischief of your grooves<br>Or should you wait and count on your troops?</p><p>It is in this moment to unleash the power of your soul!<br>It is in this moment to have a handful of desire plus hope! <br>There is a way to get through the crowd..<br>Accept your flaws, Listen to the echoes and not the horde.</p><p>Now, Would you mind reaching the last day of your life?</p><p>Having half lived when you could have stunningly thrived.</p><p>So, Believe in the power of practice and persistence<br>Because nothing would you get just by a touch...<br>As a Sculptor never becomes a Master in a day or in rush.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5655f01e00f8" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>