<?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 Parag Radke on Medium]]></title>
        <description><![CDATA[Stories by Parag Radke on Medium]]></description>
        <link>https://medium.com/@paragradke?source=rss-ed6661465833------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*xC-nWKgBzYHrU2fQ.jpeg</url>
            <title>Stories by Parag Radke on Medium</title>
            <link>https://medium.com/@paragradke?source=rss-ed6661465833------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 15 Nov 2026 19:05:55 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@paragradke/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[Probabilistic Graphical Models — Introduction]]></title>
            <link>https://medium.com/data-science/probabilistic-graphical-models-introduction-f7c919069d5c?source=rss-ed6661465833------2</link>
            <guid isPermaLink="false">https://medium.com/p/f7c919069d5c</guid>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[probability]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[statistics]]></category>
            <dc:creator><![CDATA[Parag Radke]]></dc:creator>
            <pubDate>Fri, 13 Oct 2017 13:34:33 GMT</pubDate>
            <atom:updated>2019-05-23T09:02:09.631Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*x2hkF57gsyXbO0TpEspwWw.png" /></figure><p>Probabilistic graphical models or PGM are frameworks used to create <strong>probabilistic</strong> <strong>models </strong>of<strong> complex real world scenarios </strong>and represent them in<strong> compact graphical representation</strong>. This definition in itself is very abstract and involves many terms that needs it’s own space, so lets take these terms one by one.</p><p><strong>Model<br></strong>A Model is a declarative representation of a real world scenario or a problem that we want to analysis. When I say declarative it means it’s not derived but declared or defined either by a domain expert using its domain knowledge of the problem or by using statical learning algorithms from historic data set, and then represented using any mathematical tools like graph or even simply by an equation. <br>For ex in <a href="https://medium.com/@paragradke/simple-linear-regression-2421076a5892">Liner Regression</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hf6MWRIzmXGq7ka1MXH8sw.png" /><figcaption>Where <strong>Y</strong> is the outcome we want to predict given the feature vector <strong>X</strong> that affects the output. So here <strong>we assume (model) Y as a linear function of the input X which is parameterised by Theta.</strong></figcaption></figure><p>Why we need to model the problem? Because of two main reasons<br>1. It allows us to translate an unstructured real world problem in to a structured mathematical representation<br>2. It allows us to isolate the problem (model representation) with it’s solution (algorithm), meaning once we have a mathematical model for our problem we can apply any algorithm to solve it, e.g. for the above model we can either solve it using gradient decent or any other method, model doesn’t change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VdlYFHl98J0yRaOUvvHJuA.png" /></figure><p><strong>Probabilistic<br></strong>The nature of the problem that we are generally interested to solve or the type of queries we want to make are all probabilistic because of <strong>uncertainty</strong>. There are many reasons that contributes to it. For example, incomplete knowledge of the problem, noisy observations or some attributes that contributes to the problem but can’t/hasn’t included in the model.</p><p><strong>Graphical<br></strong>In the example above we used a mathematical representation of the model but in real world scenarios are complex and often involves large no of variables. So many times a graphical representation helps us to visualise better and then we use <strong>Graph Theory</strong> to reduce the no of relevant combinations of all the participating variables to represent the high dimensional <strong>probability distribution</strong> model more compactly.</p><p>There are some basic terms &amp; concepts related to probability and statistics I will be using to discuss PDMs. Those are covered in a separate post <a href="https://medium.com/@paragradke/basic-probability-theory-and-statistics-3105ab637213"><strong>Basic Probability Theory and Statistics</strong></a><strong>.</strong></p><p>A model is generally useful if it helps us to understand the real world phenomena allows us to make useful predictions about how the world will behave <em>under certain set of conditions</em>. The kind of quires we often want to do on our models are of nature is to predict what will likely to happen when something else is already happened/observed. To answer such queries we need to consider all components (random variables) of that state of the world and represent them some how. We already learned “<a href="https://medium.com/towards-data-science/basic-probability-theory-and-statistics-3105ab637213">joint distribution</a>”, we represents all possible outcomes of an event. So it means we got the tool to represent our model which can cover all possible scenarios and that is ‘Joint Probability Distribution Table’ (For time being restrict ourself to discrete random variables only). Then why we are discussing PGMs?<br>The problem is even for a simple model the number of variables <strong>n</strong> can be in the range of 100s and if each can obtain on an average <strong>d</strong> values, the size of the joint distribution table can be very-2 large. So tables may not be a feasible way to represent complex models though the conceptually they are sufficient, computational limitation don’t allow them. We need some other representation, and it seems Graphs because of it’s sparse nature can be a good fit. There are number of advantages of using graphs to represent such probabilistic models.</p><ol><li>Even though there are large number of random variables involved not necessarily they all depends on each other. And if the two random variables are independents we don’t need to consider their all combinations in join distribution table, which means ideally there will be lesser rows in the table. Graph Theory has inherent capability to represent such dependence and independences.</li><li>Graphs representation is flexible in a sense that one doesn’t require to obtain all the knowledge about world to build a model. One can start with his understanding of the world and build a model and it’ll behave based on the knowledge it has. When one acquire more knowledge it can apply the same incrementally to the model (Add/Update nodes, edges) and model will produce improved results based on new information.</li><li>As graph are standard mathematical structure it not only allows to encode probability distribution but also provide a very clear interface to query model for prediction queries.</li></ol><p>As PGMs are based on Graph Theory they can be categories in to two categories as <strong>Directed Graphs</strong> or <strong>Undirected Graphs</strong>. There is one family of PGM uses Directed Graphs is <strong>Bayesian Networks </strong>and other that uses undirected graphs is<strong> Markov Networks</strong>. Even though they both derived from Graph Theory there are so many differences in both of their intuitions and each require it’s own space ‘ll discuss them in separate posts.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f7c919069d5c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/probabilistic-graphical-models-introduction-f7c919069d5c">Probabilistic Graphical Models — Introduction</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[Gaussian Discriminant Analysis 
an example of Generative Learning Algorithms]]></title>
            <link>https://medium.com/data-science/gaussian-discriminant-analysis-an-example-of-generative-learning-algorithms-2e336ba7aa5c?source=rss-ed6661465833------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e336ba7aa5c</guid>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[probability]]></category>
            <dc:creator><![CDATA[Parag Radke]]></dc:creator>
            <pubDate>Fri, 29 Sep 2017 22:46:03 GMT</pubDate>
            <atom:updated>2017-09-30T18:10:29.629Z</atom:updated>
            <content:encoded><![CDATA[<p>Gaussian Discriminant Analysis <br>an example of Generative Learning Algorithms</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/700/1*51e4Y6kZIEi-iKiuI0_wqQ.jpeg" /></figure><p>Generative Learning Algorithms: <br>In <a href="https://medium.com/@paragradke/simple-linear-regression-2421076a5892">Linear Regression</a> and <a href="https://medium.com/@paragradke/logistic-regression-2b555e5f80e6">Logistic Regression</a> both we modelled conditional distribution of y given x, as follow.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*krT9h3D-fiagy1ssurPCDA.png" /></figure><p>Algorithms that model p(y|x) directly from the training set are called <strong>discriminative algorithms</strong>. <br>There can be a different approach to the same problem, consider the same binary classification problem where we want learn to distinguish between two classes, class A (y=1) and class B (y=0) based on some features. Now we take all the examples of label A and try to learn the features and build a model for class A. Then we take all the examples labeled B and try to learn it’s features and build a separate model for class B. Finally to classify a new element, we match it against each model and see which one fits better (generate high value for probability). In this approach we try to model p(x|y) and p(y) as oppose to p(y|x) we did earlier, it’s called <strong>Generative Learning Algorithms</strong>.<br>Once we learn the model p(y) and p(x|y) using training set, we use Bayes Rule to derive the p(y|x) as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fD5M2fz-h3LSJpu9eknTyg.png" /></figure><p><strong>Gaussian discriminant analysis model<br></strong>When we have a classification problem in which the input features are continuous random variable, we can use GDA, it’s a generative learning algorithm in which we assume p(x|y) is distributed according to a <strong>multivariate normal distribution</strong> and p(y) is distributed according to <strong>Bernoulli</strong>. So the model is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Eiy_EsrtbPwaTJNooDdAtA.png" /></figure><p>Now as we did in <a href="https://medium.com/@paragradke/simple-linear-regression-2421076a5892">Linear Regression</a> and <a href="https://medium.com/@paragradke/logistic-regression-2b555e5f80e6">Logistic Regression</a>, we need to define the log likelihood function <strong>L</strong> and then by maximising <strong>L</strong> with respect to model parameters, find the maximum likelihood parameters.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mw42sVL7b9rKl6qcQpdYew.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FXkiaZ8d1pBEfSkP58tSYg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*FItEShlB9YO1f5lLx6Vvrw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mImNZxXtGT98KrjqHFTOPg.png" /></figure><p>So Eq(2) , Eq(4) and Eq(5) defines all the maximum likelihood parameters of GDA as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NeeSLnPEoPI8f0p6Y0oCcQ.png" /><figcaption>Model parameters for GDA</figcaption></figure><p>Example: I used a custom <a href="https://gist.github.com/paragradke/4044ad2d567f6b0cd62888afb104c177">iris</a> dataset (reduced features to fit it in to two dimensions and removed the 3rd class from the data set to make it for binary classification)for this example.The data plot looks as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*CKLTHuYnUts8VSTI3CM5JQ.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/8a0e9ff580fd36c0db3d59caea0fa2c9/href">https://medium.com/media/8a0e9ff580fd36c0db3d59caea0fa2c9/href</a></iframe><p>For the <a href="https://gist.github.com/paragradke/4044ad2d567f6b0cd62888afb104c177">dataset</a> computed model parameters are as below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pzMbEp3tLVRFFnx1pxKTSw.png" /></figure><p>Based on the algorithm the probability density plots for each models look as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/916/1*5guogPhnt2vIzEm17JGS-Q.png" /><figcaption>3D Surface Plot for p(x|y=1)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/914/1*A5Rm6u6aN_-p90QopZW25w.png" /><figcaption>3D Surface Plot for p(x|y=0)</figcaption></figure><p>And from their contour plots you can see the models explains the test data. The surface of the models are not smooth (As the assumption p(x|y) is guassian is not perfectly true for this particular test data. And will discuss how it affects the accuracy of the model) and so the contours will also not be smooth but noisy.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y1X1iYz14FLUpwkqD8uCRA.png" /><figcaption>Contour Plot for p(x|y=0) with data points for class y=0</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jxpSP8Nq3jSJc6z_UbVReQ.png" /><figcaption>Contour Plot for p(x|y=1) with data points for class y=1</figcaption></figure><p>Lets take two test points to test our algorithm as <br><strong>x0 = [4, 4]<br>x1 = [6.5, 2.25]</strong></p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/b72ff7dd2ae9ec307736963529cdaf5f/href">https://medium.com/media/b72ff7dd2ae9ec307736963529cdaf5f/href</a></iframe><p>You can see the algorithm favours the <strong>class 0</strong> for <strong>x0</strong> and <strong>class 1</strong> for<strong> x1</strong> as expected. Both <a href="https://medium.com/@paragradke/logistic-regression-2b555e5f80e6">Logistic Regression</a> and Gaussian Discriminant Analysis used for classification and both will give a slight different <strong>Decision Boundaries</strong> so which one to use and when.<br>GDA makes an assumption about the probability distribution of the p(x|y=k) where k is one of the classes. And it can be easily proved that for GDA, if the initial assumptions about distribution of p(x|y=k) (<strong>Gaussian</strong>)and p(y)(<strong>Bernoulli)</strong> are true, then p(y|x) can be expressed as <strong>Sigmoid. </strong>But vice-versa is not true. <strong>Which means GDA makes more specific assumptions about the data set then </strong><a href="https://medium.com/@paragradke/logistic-regression-2b555e5f80e6"><strong>Logistic Regression</strong></a><strong> and if those assumptions are true then it works better then LR</strong>. This fact can be useful when you know better about the nature of the dataset you’re dealing with and which is Gaussian, and you don’t have a large training set, in situations like this GDA will perform better then LR<strong>. But on the other hand LR makes more generic assumptions and can be more useful in lot of other places where the probability distribution of the feature set is not Gaussian.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e336ba7aa5c" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/gaussian-discriminant-analysis-an-example-of-generative-learning-algorithms-2e336ba7aa5c">Gaussian Discriminant Analysis 
an example of Generative Learning Algorithms</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[Logistic Regression]]></title>
            <link>https://medium.com/data-science/logistic-regression-2b555e5f80e6?source=rss-ed6661465833------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b555e5f80e6</guid>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[logistic-regression]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Parag Radke]]></dc:creator>
            <pubDate>Thu, 14 Sep 2017 12:57:04 GMT</pubDate>
            <atom:updated>2017-10-11T00:13:26.086Z</atom:updated>
            <content:encoded><![CDATA[<p>“It is more important to have beauty in one’s equations than to have them fit experiment…” — Paul Dirac</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7MB750ebyUa9Jc7UiMRpEw.png" /></figure><p>This is also know as ‘<strong><em>Classification</em></strong>’. This is used in many scenarios where we want to categories input in predefined classes. For ex. tag email as spam/non spam, predict the age group of a customer from the data of commerce portal etc.<br>In <a href="https://medium.com/@paragradke/simple-linear-regression-2421076a5892"><strong><em>linear regression</em></strong></a> the output domain is a continues range, i.e. it’s a infinite set, while in logistic regression the output <strong><em>y</em></strong> we want to predict takes only a small no of discrete values. i.e. it’s Finite Set. For simplicity lets consider a binary classification where y can take only two values, 1 (positive) and 0 (negative). <br>Just like linear regression we need to start with a hypothesis. As the output domain is bounded (0,1) it doesn’t make sense to have a hypothesis which produces value beyond this range.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*T1x0ypGSBKbIY5KI_Jb0xw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jFcWzXMmmzWKfbFpXf4I5g.png" /><figcaption>plot of f(x) for x belongs to (-10, 10)</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZYD_Urf5xKs982Bf1WJLuQ.png" /></figure><p>Given the above set of logistic regression models (why set? because theta is variable) we need to find the co-efficient theta for the best fit model which best explains the training set. For that we need to start with a set of probabilistic assumptions parameterised by theta and then find the theta via <strong>Maximum Likelihood</strong>. <br>Lets start with <strong>Bernoulli distribution </strong>, the probability distribution of a random variable which takes the value of 1 with probability p and value 0 with probability q= 1-p.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6hkVirgrDqDVWCdjl2xZKQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iV1eKXj5ACL9mnW9lPMOGA.png" /></figure><p>In <a href="https://medium.com/@paragradke/simple-linear-regression-2421076a5892"><strong><em>linear regression</em></strong></a><strong><em> </em></strong><em>we</em><strong><em> </em></strong>find the coefficients by equating the derivative of log likelihood to zero. We evaluated the derivative of likelihood just like we did but the resultant Ex(3) is not a mathematically closed equation that we can solve. (Remember x and theta both are vectors in the eq and h is a non linear function)<br>We can still find the coefficient by using a brute force algorithm called <strong><em>Gradient Ascent. </em></strong>where we start with some<strong><em> </em></strong>coefficient and then keep updating theta iteratively until the likelihood function converges.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BBdzr7pNuvVkpr7CHSdmTg.png" /></figure><p><strong>Example<br></strong>Let’s take the <a href="https://en.wikipedia.org/wiki/Logistic_regression#Example:_Probability_of_passing_an_exam_versus_hours_of_study">wikipedia example</a> <br>Suppose we wish to answer the following question:</p><blockquote><em>A group of 20 students spend between 0 and 6 hours studying for an exam. How does the number of hours spent studying affect the probability that the student will pass the exam?</em></blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bWFHy0nVT1925UqYm8RAQA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*joEh6cwWq2JaoKXr1LG5yQ.png" /></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/bd2f3c61e1de570f911eb5e864a1114e/href">https://medium.com/media/bd2f3c61e1de570f911eb5e864a1114e/href</a></iframe><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*1ORdlJsKgNgAqXFxlivPIA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SXNiMSG5mM2oeYfssbzw1Q.png" /><figcaption>Plot of derived model for the range (0,6)</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b555e5f80e6" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/logistic-regression-2b555e5f80e6">Logistic Regression</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[Linear Regression]]></title>
            <link>https://medium.com/data-science/simple-linear-regression-2421076a5892?source=rss-ed6661465833------2</link>
            <guid isPermaLink="false">https://medium.com/p/2421076a5892</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[linear-regression]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[linear-algebra]]></category>
            <dc:creator><![CDATA[Parag Radke]]></dc:creator>
            <pubDate>Wed, 06 Sep 2017 18:43:59 GMT</pubDate>
            <atom:updated>2017-10-19T17:31:06.087Z</atom:updated>
            <content:encoded><![CDATA[<p>“An approximate answer to the right problem is worth a good deal more than an exact answer to an approximate problem.” — John Tukey</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oXPGYqgTeIn0Ey3SWgkbsA.jpeg" /></figure><p><strong>linear regression</strong> is a linear approach for modeling the relationship between a scalar dependent variable <em>y</em> and one or more or independent variables denoted <em>X. </em>Unlike <a href="https://medium.com/@paragradke/logistic-regression-2b555e5f80e6">Logistic Regression</a> the dependent variable here can take a continues range of values. The relationships are modeled using linear predictor functions called <strong>Linear Hypothesis</strong>, whose unknown model parameters are estimated from the data.<br>Lets start with a linear hypothesis.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/726/1*HaCVp7uBhV-4eV2HFjH9Bg.png" /></figure><p><strong>Where</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/470/1*w2bAE9wraHDm9PcWnW9yHQ.png" /></figure><p>We can write the same in concise notation as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*aS3G6gAQA4KYIJu-qcgqiA.png" /></figure><p>The above equation signifies that given a new input feature vector <strong><em>x</em></strong> the predicted value of the output will be given by the hypothesis <strong><em>h</em></strong>. So the accuracy of the predictions depends on the <strong><em>weights of the input features.</em></strong></p><p>If we denote actual output values for the <strong><em>m</em></strong> training examples by a vector <strong><em>y </em></strong>of size m. One reasonable way is to use training set to make value of <strong><em>h </em></strong>as close to<strong><em> y. </em></strong>We<strong><em> </em></strong>define the actual difference as <strong><em>cost function</em></strong> <strong><em>J</em></strong> given by.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*2FSFo2bSikuK2Yjv_-RFEA.png" /></figure><p>So now the equation becomes find <strong><em>weights</em></strong> for which <strong><em>cost function J</em></strong> is minimum.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/350/1*NLYL9bEcZeIgDOFdVU23Og.png" /></figure><p>Let</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QW-S8-_K-_1v1z_-EHR7zg.png" /></figure><p>Where<br><strong>Y</strong> : is output vector for <strong>m training examples.<br>X </strong>: is matrix of size <strong>m*n</strong> where each ith row belongs to ith training set.<br><strong>Q</strong> : is weight vector of size n for <strong>n</strong> training features.<br>So</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/748/1*BM_fkGXnueCESc74Lmqmjw.png" /></figure><p>And</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/904/1*5Z12W82-C9IHuTeGV8duTQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3RHBj896-tH_30cTtCyybw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WGo8bn4FmwqHJ6IeYBSBDQ.png" /></figure><p>Which results In</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/268/1*6K_yGuXGIZy5-rB7FgppQQ.png" /></figure><p><strong>Example:<br></strong>Given Training set <a href="http://college.cengage.com/mathematics/brase/understandable_statistics/7e/students/datasets/slr/frames/slr06.html">here</a><br>X = number of claims<br>Y = total payment for all the claims in thousands of Swedish Kronor</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TFsk0QaEd46wx8CgL16fEg.png" /><figcaption>Plot of Y w.r.t. X.</figcaption></figure><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/6b33be0fe50be4f9744ac90dfaf94600/href">https://medium.com/media/6b33be0fe50be4f9744ac90dfaf94600/href</a></iframe><p>The above will Resolve to</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/226/1*JN4eGzCNyT5K7tzbPp4uhw.png" /></figure><p>And Finally the model will be</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/338/1*NYd26HZ0nw7Z8oJKugmIeg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zNDBVPZtWn0mE3I8ZQCjOg.png" /><figcaption>The plot of data along with model fitting the data.</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2421076a5892" width="1" height="1" alt=""><hr><p><a href="https://medium.com/data-science/simple-linear-regression-2421076a5892">Linear Regression</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[Vector/Matrix Calculus]]></title>
            <link>https://paragradke.medium.com/vector-matrix-calculus-6b8c06fbf9a7?source=rss-ed6661465833------2</link>
            <guid isPermaLink="false">https://medium.com/p/6b8c06fbf9a7</guid>
            <category><![CDATA[calculus]]></category>
            <category><![CDATA[mathematics]]></category>
            <category><![CDATA[matrix]]></category>
            <category><![CDATA[vector]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Parag Radke]]></dc:creator>
            <pubDate>Wed, 06 Sep 2017 12:28:21 GMT</pubDate>
            <atom:updated>2017-09-06T14:39:30.794Z</atom:updated>
            <content:encoded><![CDATA[<p>Calculus has its own limits :)</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P-jCQu6fhfliMLPz5-BYdQ.jpeg" /></figure><p><strong>Definition: <br>matrix calculus</strong> is a specialised notation for doing <strong>multivariable calculus</strong>. It collects the various <a href="https://en.wikipedia.org/wiki/Partial_derivative">partial derivatives</a> of a single function with respect to many variables, and/or of a multivariate function with respect to a single variable, into vectors and matrices that can be treated as single entities.<br>The six kinds of derivatives that we are going to discuss can be organised in a matrix as below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LziAe9XkXOnV6s4trpVxAw.png" /><figcaption>Here matrix is used in general term. For ex vectors are also 1 dimensional matrix and scalar is a single element matrix.</figcaption></figure><p><strong>Scalar By Scalar:<br></strong>If y is defined as continuous and differentiable function of x for the range (x1, x2) such that.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uuVdlduG77qKGERLPwD5ig.png" /></figure><p>And it’s equal to the slope of function y at point x=t. It can also be understood as rate of change y w.r.t to infinitely small change in x.<br><strong>Ex:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LC352klM9mXQgoiws5oCmA.png" /></figure><p><strong>Vector by Scalar:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hbbbhFxdMEqqbJNBBPdziQ.png" /></figure><p><strong>Ex:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XejR8nEnDpIg_72I849uOA.png" /></figure><p><strong>Matrix by Scalar:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*up8J_QOOde7qdPDPTCLMRw.png" /></figure><p><strong>Ex:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*u1kK3BC381MaEyCYo2incw.png" /></figure><p><strong>Scalar By Vector:<br></strong>Let y is a scalar function of n independent variables such that</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ev1mhVIthU43rJd2L5fZbA.png" /></figure><p>Then the derivative of y w.r.t to vector <strong>x</strong> is given by the vector equation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F1hYYgdHgHVGC5yr25_mHQ.png" /></figure><p><strong>Ex:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VwjQ_0CW-UUOcJHOFmx5wg.png" /></figure><p><strong>Vector By Vector:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z6VWjPr0rr3LHmoFFrzQqA.png" /></figure><p><strong>Ex:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MoweE0dqPmv28r8MCnEweA.png" /></figure><p><strong>Scalar By Matrix</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7LSQXKP0gknHPGXTceiydQ.png" /></figure><p><strong>Ex:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A3Na-yDvxdEXIjw8HjhuRw.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6b8c06fbf9a7" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Vector/Matrix Algebra]]></title>
            <link>https://paragradke.medium.com/vector-matrix-algebra-i-c3965963bd04?source=rss-ed6661465833------2</link>
            <guid isPermaLink="false">https://medium.com/p/c3965963bd04</guid>
            <category><![CDATA[vector]]></category>
            <category><![CDATA[matrix]]></category>
            <category><![CDATA[machine-learning]]></category>
            <dc:creator><![CDATA[Parag Radke]]></dc:creator>
            <pubDate>Tue, 05 Sep 2017 09:27:19 GMT</pubDate>
            <atom:updated>2017-09-05T10:46:42.089Z</atom:updated>
            <content:encoded><![CDATA[<p>What is the Matrix?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*XZrU5omVCZPZXuYv2AZnog.jpeg" /></figure><p><strong>Matrix<br></strong> The ordered rectangular array</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/404/1*B2UKflGxTfgEp3h_N-7Kgg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/92/1*sFYTL1jdtP3ViucpDZPrDg.png" /></figure><p>Is called a Matrix of order m*n<br>where i=1,2,3… m and j=1,2,3… n.</p><p><strong>Vector<br></strong>A vector is a matrix with only one column.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/166/1*Fzionn3Tzz9ziHnXY5VmhA.png" /></figure><blockquote>Note:<br>Multicolumn matrices are denoted by bold uppercase alphabets like <strong>A, B … Z<br></strong>Vectors are denoted by bold small case letters like alphabets like <strong>a</strong>, <strong>b</strong>… <strong>z</strong></blockquote><p><strong>Null Matrix<br></strong> Null matrix is a matrix all elements <strong>0</strong>s. It’s denoted by <strong>Z </strong>and defined as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/214/1*u5qdurFrofcf5qCoAZS-iQ.png" /></figure><p><strong>Equal Matrix<br></strong>Let</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/376/1*dZnts9UncpioXV8Cp8fLFw.png" /></figure><p>And</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/370/1*IFa-eXAGgGh8qaObb4_JCw.png" /></figure><p>Then A=B if and only if they are of same order and all corresponding elements are also equal i.e. n=q and m=p and</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/234/1*-PwUiQgYPHjPL7VWwpWyEw.png" /></figure><p><strong>Identity Matrix<br></strong> Identity matrix is a square matrix with <strong>1</strong>s on all the main diagonal positions and <strong>0</strong>s every where else. It’s denoted by <strong>I </strong>and defined as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/280/1*g3FZsFFDXbbvRvryj4bxrQ.png" /></figure><p><strong>Ex:</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/248/1*iHxpam_A8d2A2uC-TPn7rA.png" /></figure><p><strong>Matrix Addition<br></strong>The addition of two matrix is only defined if they are of same order.<br>Let<br><strong>A(m * n) &amp; B(m * n</strong>)<br>Then it’s summation <strong>C</strong> = <strong>A</strong> + <strong>B</strong> is defined as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/334/1*JGKERImdtFsiTMrkEe9-0g.png" /></figure><p>For all i = 1, 2, 3 … m j = 1, 2, 3 … n<br><strong>C</strong>’ll be <strong>m * n</strong> matrix</p><p><strong>Matrix Scalar Multiplication<br></strong>Let</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/146/1*WrDSjsIXd6rNheTzZrj3Bg.png" /></figure><p>Then their product is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/106/1*xt7JTExvfprqgOJ9zNJgjA.png" /></figure><p>is a matrix <strong>B</strong> of order <strong>m*n </strong>whose elements are defined as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/178/1*57NM8sViaEM98Jqp08NWxQ.png" /></figure><p><strong>Matrix Multiplication<br></strong> Two matrices are multiplicable if and only if they are of orders <strong>A</strong>(<strong>m*n)</strong> and <strong>B</strong>(<strong>n*p).</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/304/1*vaq_OVhx54aCBVwVV7P-UA.png" /></figure><p>And it’s product <strong>C</strong> = <strong>AB</strong> is defined as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/244/1*_lo_9-YCsRtXV7g_xH8TIA.png" /></figure><p>For all i = 1, 2, 3 … m j = 1, 2, 3 … p. <br><strong>C</strong>’ll be <strong>m * p </strong>matrix</p><p><strong>Matrix Transpose<br></strong>Transpose of a matrix <strong>A</strong> is denoted as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/46/1*sUdCKxT3N8IuKZ2W2tI2UQ.png" /></figure><p>and is defined as a matrix whose elements are given by eq</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/1*mRTCWgmfGE9q7drvZ_CS3g.png" /></figure><p><strong>Matrix Trace<br></strong>Trace of a matrix is defined only for square matrix. Let <strong>A</strong> is (<strong>n*n). </strong>Then trace of the matrix <strong>A,</strong> <strong>tr(A)</strong> is defined as sum of all the elements on it’s main diagonal.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*Uq0MFVrVuxM-JpMu-zhtEA.png" /></figure><p><strong>SubMatrix<br></strong>Let <strong>A</strong> is <strong>m*n </strong>matrix. Then the sub matrix is (<strong>m-1</strong>)*(<strong>n-1</strong>) matrix obtained from A by removing row i and column j.<br>Ex</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/296/1*pC_aXeECL_oVK9gBrjnNqQ.png" /></figure><p>Then sub matrix</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*vdhsOYadjJhb1qJiKLEYgA.png" /></figure><p><strong>Matrix Determinant<br></strong>Determinant of a matrix is only defined for square matrix.<br>Let <strong>A</strong> is square matrix<br>Then determinant of <strong>A</strong> is denoted as <strong>det(A)</strong> or <strong>|A|</strong> and is defined as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/998/1*XyXIug7ZbKXCWfaVVieGPQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/910/1*jtODhtx195aUy8V8EjD07Q.png" /></figure><p><strong>Cofactor Matrix<br></strong>Cofactor matrix is defined for only square matrix. <br>Let <strong>A</strong> is <strong>n*n </strong>matrix. Then cofactor matrix <strong>C of A </strong>is defined as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/368/1*yugriXfDaanz6CUtff08Yg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WLOgKiFOtB-JVV9HRiyUqg.png" /></figure><p><strong>Adjugate of a Matrix<br></strong>Adjugate of a matrix is defined only for square matrix.<br>Let <strong>A</strong> is <strong>n*n </strong>matrix. Then Adjugate of A is denoted by <strong>adj(A)</strong> and is defined as.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/242/1*pebBN8A9jM5awgGpLxasMQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*INJc6nNOMexGve_1bAc5CQ.png" /></figure><p><strong>Inverse of Matrix<br></strong>Inverse of a matrix is defined for only for square matrix.<br>Let <strong>A</strong> is (<strong>n*n) </strong>matrix<br>Inverse of a matrix is denoted as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/58/1*fm5KBfuQLjjoH0YTGQTVcQ.png" /></figure><p>And is defined as</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/186/1*LMi6nzXpW9lRdsxEoAsE7w.png" /></figure><p>Where<strong> I </strong>is an identity matrix of order <strong>n</strong>. A is invertible if and only if</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/106/1*GazM-TZCLz6GHWvIC2QnwA.png" /></figure><p>And is evaluated by the equation</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*9Nmjx6x1C7a8a3j4yPXLiQ.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c3965963bd04" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>