{"id":66,"date":"2014-10-23T21:32:51","date_gmt":"2014-10-23T21:32:51","guid":{"rendered":"http:\/\/gallego.ca\/blog\/?p=66"},"modified":"2022-04-23T21:07:05","modified_gmt":"2022-04-23T21:07:05","slug":"discriminant-analysis-from-a-bayesian-point-of-view","status":"publish","type":"post","link":"http:\/\/gallego.ca\/myblog\/discriminant-analysis-from-a-bayesian-point-of-view\/","title":{"rendered":"Discriminant analysis from a Bayesian point of view"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\">In LDA and QDA it is assumed that the the class-conditional densities represent a sample from a multivariate Gaussian distribution, that makes the likelihood function a normal distribution:<br>$$f_k(x) \\sim N(\\mu, \\Sigma)$$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We model each class density as multivariate Gaussian:<br>$$f_k(x) = \\frac{1}{2\\pi |\\Sigma_k|^{1\/2}}exp^{-\\frac{1}{2}(x-\\mu_k)^T\\Sigma_k^{-1}(x-\\mu_k)}$$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">when we do Linear discriminant analysis (LDA), an assumption of common covariance matrices is made, which leads to a linear function of x. This means that the Gaussian distributions are shifted versions of each other.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">The <strong>covariance matrix<\/strong> defines the shape of the data. if on average, when the x-value of a data point increases, and also the y-value increases, there&#8217;s a clear positive diagonal correlation.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Notation:<\/strong> The prior probability of each class \\(k\\) is \\(\\pi_k\\), which is in practice estimated by the empirical frequencies in the training set:<br>$$\\pi_k = \\frac{\\text{count samples in class k}}{\\text{total count of samples}}$$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Each class conditional density of x is assumed to be a gaussian, \\(C_k = f_k(x)\\)<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">For each case, the posterior probability of x given class \\(k\\) can be computed as:<br>$$Pr(C=k|X=x) = \\frac{ f_k(x)\\pi_k}{\\sum_{i=1}^K f_i(x\\pi_i}$$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Then, the class assigned to each case, by MAP assignement, using Bayes rule is:<br>$$\\hat{C}_x = \\text{arg max}_k Pr(C=k|X=x)$$<br>$$= \\text{arg max}_k f_k(x)\\pi_k$$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">First, let&#8217;s generate some random dataset Set1 from a 2d-gaussian:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">n1 &lt;- 1000  # number of samples\nm1 &lt;- c(0,0)  # mean\nsd1 &lt;- c(0.5, 0.5)  # standard deviation\ncor1 &lt;- matrix(c(1, 0.3, 0.3, 1), ncol = 2)  # correlation matrix\n# You can rescale the correlation matrix by pre-and post-multiplying by a diagonal matrix that contains the standard deviations:\ncov1 &lt;- diag(sd1) %*% cor1 %*% diag(sd1)\nbivn1 &lt;- mvrnorm(n1, mu=m1, Sigma=cov1)\nbivnden1 &lt;- kde2d(bivn1[,1], bivn1[,2], h = rep(2, 2), n = 100)\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Now, we create Set2, also from a Gaussian density, such as Set2 is a shifted version of Set1 (i.g they have the same covariance matrix, but different mean)<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">n2 &lt;- 1000  # number of samples\nm2 &lt;- c(2,-2)  # mean\nbivn2 &lt;- mvrnorm(n2, mu=m2, Sigma=cov1)\nbivnden2 &lt;- kde2d(bivn2[,1], bivn2[,2], h = rep(2, 2), n = 100)\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Then, combining the two bivariate normals and plotting:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">bivn &lt;- rbind(bivn1, bivn2)\nlibrary('ash')\nbivn2d &lt;- bin2(bivn, nbin=c(30, 30)) # turn into a bin count matrix\nbivn2dest &lt;- ash2(bivn2d)  # Compute bivariate estimate  \nfilled.contour(bivn2dest, xlab = \"x\", ylab = \"y\",\n    main = \"Bivariate Gaussian Density\", key.title = title(\"\\ndensity\"))\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\"><a href=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-53\" src=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-1-300x300.png\" alt=\"\" width=\"300\" height=\"300\" srcset=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-1-300x300.png 300w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-1-150x150.png 150w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-1.png 504w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><br>As scatter plot of the samples:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">plot(bivn, xlab = \"x\", ylab = \"y\", pch = 21, \n     bg = rgb(139\/255, 137\/255, 137\/255, 0.75), col = NA, cex = 1, lwd = NA)\ncontour(bivn2dest, add=TRUE, drawlabels=FALSE, \n               col=topo.colors(12, alpha=0.8),#color.palette = colorRampPalette(c(\"white\", \"cyan\", \"blue\")),\n               xlab = \"x\", ylab = \"y\", \n               main = \"Bivariate Gaussian Density for 2 bivariate\", key.title = title(\"\\ndensity\"))\n<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"300\" src=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-2-300x300.png\" alt=\"\" class=\"wp-image-54\" srcset=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-2-300x300.png 300w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-2-150x150.png 150w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-2.png 504w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">We can also represent the shape of the distributions using a surface plot over the x\u2013y plane:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">persp(bivn2dest, col = \"white\", border=topo.colors(12, alpha=0.8),\n      theta=15, phi=45, shade = 0.2, ticktype = \"detailed\",\n       xlab = \"X\", ylab = \"Y\", zlab = \"Pr(G=k|X=x)\")\n<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-3.png\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"300\" src=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-3-300x300.png\" alt=\"\" class=\"wp-image-55\" srcset=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-3-300x300.png 300w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-3-150x150.png 150w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-4-3.png 504w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Optimal classification:<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">For this data, the optimal classification is a MAP assignment of a class to test case x. Assuming common covariance:<br>$$\\hat{C}_x = \\text{arg max}_k Pr(C=k|X=x)$$<br>$$= \\text{arg max}_k f_k(x)\\pi_k$$<br>$$= \\text{arg max}_k log(f_k(x)\\pi_k)$$<br>$$= \\text{arg max}_k [ -log(2\\pi |\\Sigma|^{1\/2}) -\\frac{1}{2}(x-\\mu_k)^T\\Sigma^{-1}(x-\\mu_k) + log(\\pi_k) ]$$<br>$$= \\text{arg max}_k [-\\frac{1}{2}(x-\\mu_k)^T\\Sigma^{-1}(x-\\mu_k) + log(\\pi_k)]$$<br>$$= \\text{arg max}_k [x^T\\Sigma^{-1}\\mu_k -\\frac{1}{2}\\mu_k^T\\Sigma^{-1}\\mu_k -\\frac{1}{2}x^T\\Sigma^{-1}x + log(\\pi_k)]$$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can conclude that:<br>$$\\hat{C}_x = \\text{arg max}_k [x^T\\Sigma^{-1}\\mu_k -\\frac{1}{2}\\mu_k^T\\Sigma^{-1}\\mu_k + log(\\pi_k)]$$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">If we define the linear discriminant function:<br>$$\\delta_k(x) = x^T\\Sigma^{-1}\\mu_k -\\frac{1}{2}\\mu_k^T\\Sigma^{-1}\\mu_k + log(\\pi_k)$$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">We can express the decision boundary between class \\(k\\) and \\(l\\) in terms of the discriminant function, since at the boundary the following holds:<br>$${x: \\delta_k(x) = \\delta_l(x)}$$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Equivalently:<br>$$log \\frac{\\pi_k}{\\pi_l} &#8211; \\frac{1}{2}(\\mu_k+\\mu_l)^T\\Sigma^{-1}(\\mu_k-\\mu_l) + x^T\\Sigma^{-1}(\\mu_k-\\mu_l) = 0$$<\/p>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Example:<\/strong><br>Using the 2 datasets from 2d-gaussians, shifted means equal covariance. For a binary classification \\((k = 1, l = 2)\\):<br>Defining:<br>$$a_0= log \\frac{\\pi_k}{\\pi_l} &#8211; \\frac{1}{2}(\\mu_k+\\mu_l)^T\\Sigma^{-1}(\\mu_k-\\mu_l)$$<br>and \\(a_j^T = \\Sigma^{-1}(\\mu_k-\\mu_l)\\)<br>Then, classify as class \\(K=1\\), if:<br>$$a_0 + \\sum_{j=1}^K a_jx_j &gt; 0$$<br>classify class \\(K=2\\), otherwise.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">Let&#8217;s look at our simulated example:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># writing equation for classification rule:\na0 = log(0.651\/0.349) - 0.5*t(m1+m2)%*%ginv(cov)%*%(m1-m2)\n# coefficients x1 and x2:\naj = ginv(cov)%*%(m1-m2)\n# classification rule (decision boundary by LDA)\nprint(paste(a0,aj[1],\"x1\",aj[2],\"x2 &gt; 0\"))\n<\/pre>\n\n\n\n<pre class=\"wp-block-preformatted\">## [1] \"0.774616834455073 -0.677099267216323 x1 -0.392884575532226 x2 &gt; 0\"\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Create a contour plot for the density (mixture of two Gaussians) simulated data:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">plot(bivn1, ylim=c(-4,2), xlim=c(-3,4), col=\"red\", pch=8, xlab=\"x\", ylab=\"y\")\npar(new=TRUE)\nplot(bivn2, ylim=c(-4,2), xlim=c(-3,4), col=\"green\", pch=1, xlab=\"x\", ylab=\"y\", \n     main=\"2 simulated Gaussian datasets, decision rule is linear in x\")\nabline(a=a0\/-aj[2], b=aj[1]\/-aj[2])\ncontour(bivn2dest, add=TRUE, drawlabels=TRUE, \n               col=topo.colors(12, alpha=0.8),#color.palette = colorRampPalette(c(\"white\", \"cyan\", \"blue\")), xlab=\"x\", ylab=\"y\")\n<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-6-1.png\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"214\" src=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-6-1-300x214.png\" alt=\"\" class=\"wp-image-69\" srcset=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-6-1-300x214.png 300w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-6-1-1024x731.png 1024w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-6-1.png 1344w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/figure>\n\n\n\n<h2 class=\"wp-block-heading\">Now applaying LDA &#8211; Bayesian medthod to the iris data<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">In practice we do not know the parameters of the Gaussian distributions, and will need to estimate them using our training data:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\"># for priors\np1=sum(irisdata$Species == \"versicolor\")\/nrow(irisdata)\np2=sum(irisdata$Species == \"virginica\")\/nrow(irisdata)\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">6 possible feature pair plots, 6 linear discriminants:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">d1Sepal.L=irisdata$Sepal.L[irisdata$Species == \"versicolor\"]\nm1Sepal.L =mean(d1Sepal.L)\nd2Sepal.L =irisdata$Sepal.L[irisdata$Species == \"virginica\"]\nm2Sepal.L =mean(d2Sepal.L)\nmSepal.L = c(m1Sepal.L,m2Sepal.L)\nd1Sepal.W =irisdata$Sepal.W[irisdata$Species == \"versicolor\"]\nm1Sepal.W =mean(d1Sepal.W)\nd2Sepal.W =irisdata$Sepal.W[irisdata$Species == \"virginica\"]\nm2Sepal.W =mean(d2Sepal.W)\nmSepal.W = c(m1Sepal.W,m2Sepal.W)\nd1Petal.L =irisdata$Petal.L[irisdata$Species == \"versicolor\"]\nm1Petal.L =mean(d1Petal.L)\nd2Petal.L =irisdata$Petal.L[irisdata$Species == \"virginica\"]\nm2Petal.L =mean(d2Petal.L)\nmPetal.L = c(m1Petal.L,m2Petal.L)\nd1Petal.W =irisdata$Petal.W[irisdata$Species == \"versicolor\"]\nm1Petal.W =mean(d1Petal.W)\nd2Petal.W =irisdata$Petal.W[irisdata$Species == \"virginica\"]\nm2Petal.W =mean(d2Petal.W )\nmPetal.W= c(m1Petal.W,m2Petal.W)\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">For Sepal.L vs. Sepal.W:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">covSepal.L_Sepal.W = cov(irisdata[c(1:2)], method=\"spearman\")\na0 = log(p1\/p2) - 0.5*t(mSepal.L+mSepal.W)%*%ginv(covSepal.L_Sepal.W )%*%(mSepal.L-mSepal.W)\n# coefficients x1 and x2:\naj = ginv(covSepal.L_Sepal.W )%*%(mSepal.L-mSepal.W)\n# classification rule (decision boundary by LDA)\nprint(paste(a0,aj[1],\"Sepal.L\",aj[2],\"Sepal.W &gt; 0\"))\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">The equation of the linear decision rule becomes:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">## [1] \"-0.0241617812271933 0.00198176338720263 Sepal.L 0.00324935477989965 Sepal.W &gt; 0\"\n<\/pre>\n\n\n\n<p class=\"wp-block-paragraph\">Contour plot for the density (assuming mixture of two Gaussians) for Sepal.W and Sepal.L:<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">xlimr=c(min(range(d1Sepal.L),range(d2Sepal.L)), max(range(d1Sepal.L),range(d2Sepal.L)))\nylimr=c(min(range(d1Sepal.W),range(d2Sepal.W)), max(range(d1Sepal.W),range(d2Sepal.W)))\nplot(d1Sepal.L, d1Sepal.W, ylim=ylimr, xlim=xlimr, col=\"red\", pch=19, \n     xlab=\"Sepal.L\", ylab=\"Sepal.W\")\npar(new=TRUE)\nplot(d2Sepal.L, d2Sepal.W, ylim=ylimr, xlim=xlimr, col=\"blue\", pch=1, \n     xlab=\"Sepal.L\", ylab=\"Sepal.W\",\n     main=\"Sepal.W and Sepal.L gaussian assumption, decision rule in linear in x\")\nabline(a=a0\/-aj[2], b=aj[1]\/-aj[2])\n<\/pre>\n\n\n\n<figure class=\"wp-block-image\"><a href=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-6-2.png\"><img loading=\"lazy\" decoding=\"async\" width=\"300\" height=\"214\" src=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-6-2-300x214.png\" alt=\"\" class=\"wp-image-70\" srcset=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-6-2-300x214.png 300w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-6-2-1024x731.png 1024w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-6-2.png 1344w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Plotting all discriminants:<\/strong><br><a href=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-1.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-58\" src=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-1-300x300.png\" alt=\"\" width=\"300\" height=\"300\" srcset=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-1-300x300.png 300w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-1-150x150.png 150w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-1.png 504w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a> <a href=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-2.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-59\" src=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-2-300x300.png\" alt=\"\" width=\"300\" height=\"300\" srcset=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-2-300x300.png 300w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-2-150x150.png 150w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-2.png 504w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a> <a href=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-4.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-61\" src=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-4-300x300.png\" alt=\"\" width=\"300\" height=\"300\" srcset=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-4-300x300.png 300w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-4-150x150.png 150w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-4.png 504w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a> <a href=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-5.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-62\" src=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-5-300x300.png\" alt=\"\" width=\"300\" height=\"300\" srcset=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-5-300x300.png 300w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-5-150x150.png 150w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-5.png 504w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a> <a href=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-6.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-63\" src=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-6-300x300.png\" alt=\"\" width=\"300\" height=\"300\" srcset=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-6-300x300.png 300w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-6-150x150.png 150w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-6.png 504w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a> <a href=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-3.png\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-60\" src=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-3-300x300.png\" alt=\"\" width=\"300\" height=\"300\" srcset=\"http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-3-300x300.png 300w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-3-150x150.png 150w, http:\/\/gallego.ca\/myblog\/wp-content\/uploads\/sites\/2\/2014\/11\/unnamed-chunk-7-3.png 504w\" sizes=\"auto, (max-width: 300px) 100vw, 300px\" \/><\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">References<\/h3>\n\n\n\n<p class=\"has-small-font-size wp-block-paragraph\">(<a href=\"http:\/\/research.microsoft.com\/en-us\/um\/people\/cmbishop\/PRML\/\" target=\"_blank\" rel=\"noopener\">Bishop<\/a> and <a href=\"http:\/\/statweb.stanford.edu\/~tibs\/ElemStatLearn\/\" target=\"_blank\" rel=\"noopener\">Hastie<\/a> textbooks)<\/p>\n","protected":false},"excerpt":{"rendered":"<p>In LDA and QDA it is assumed that the the class-conditional densities represent a sample from a multivariate Gaussian distribution, that makes the likelihood a normal distribution<\/p>\n","protected":false},"author":1,"featured_media":55,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[10,8,9],"tags":[],"class_list":["post-66","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-bayesian-statistics","category-r","category-statistical-learning"],"_links":{"self":[{"href":"http:\/\/gallego.ca\/myblog\/wp-json\/wp\/v2\/posts\/66","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/gallego.ca\/myblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/gallego.ca\/myblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/gallego.ca\/myblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/gallego.ca\/myblog\/wp-json\/wp\/v2\/comments?post=66"}],"version-history":[{"count":6,"href":"http:\/\/gallego.ca\/myblog\/wp-json\/wp\/v2\/posts\/66\/revisions"}],"predecessor-version":[{"id":156,"href":"http:\/\/gallego.ca\/myblog\/wp-json\/wp\/v2\/posts\/66\/revisions\/156"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/gallego.ca\/myblog\/wp-json\/wp\/v2\/media\/55"}],"wp:attachment":[{"href":"http:\/\/gallego.ca\/myblog\/wp-json\/wp\/v2\/media?parent=66"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/gallego.ca\/myblog\/wp-json\/wp\/v2\/categories?post=66"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/gallego.ca\/myblog\/wp-json\/wp\/v2\/tags?post=66"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}