<?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 Olegqm on Medium]]></title>
        <description><![CDATA[Stories by Olegqm on Medium]]></description>
        <link>https://medium.com/@olegqm?source=rss-7be31e8ed8df------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*kUlMLf3WmPtpWqT2</url>
            <title>Stories by Olegqm on Medium</title>
            <link>https://medium.com/@olegqm?source=rss-7be31e8ed8df------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 01:58:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@olegqm/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[LDA: Finding a Direction That Makes Classes Easier to Tell Apart]]></title>
            <link>https://medium.com/@olegqm/lda-finding-a-direction-that-makes-classes-easier-to-tell-apart-d776e1375c8a?source=rss-7be31e8ed8df------2</link>
            <guid isPermaLink="false">https://medium.com/p/d776e1375c8a</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[statistics]]></category>
            <category><![CDATA[linear-algebra]]></category>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[mathematics]]></category>
            <dc:creator><![CDATA[Olegqm]]></dc:creator>
            <pubDate>Thu, 15 Oct 2026 00:42:09 GMT</pubDate>
            <atom:updated>2026-10-15T09:25:43.253Z</atom:updated>
            <content:encoded><![CDATA[<p>When I was learning LDA, I wanted to understand what was behind the formulas. The recipe itself is easy to remember: compute two matrices, invert one of them, find the eigenvectors, and keep the first few. Picturing what those steps actually do to the data turned out to be harder.</p><p>Why two matrices? What does it mean to “divide” them? And how do eigenvectors help us distinguish classes? Without answers, the algorithm remains a list of commands.</p><p>So let’s start with a picture: two clouds of points and a line we can rotate. We’ll see where to point it so that the classes overlap less. The matrices can wait until we need them :)</p><p>It helps to know what a mean is and to be comfortable with vectors. We’ll go through variance, covariance, and the matrix properties we need along the way. At the end, we’ll check our understanding with a small Python example.</p><p><strong>LDA stands for Linear Discriminant Analysis.</strong> In this article, we’ll look for new coordinates that help distinguish classes whose labels we already know. Fisher’s criterion will measure the quality of a projection. We’ll also get to the LDA classifier toward the end.</p><h3>1. The Same Picture, Different Shadows</h3><p>Suppose each observation has two numerical features. They might be readings from two sensors. Put the first on the horizontal axis and the second on the vertical axis. Each observation becomes a point in the plane.</p><p>The observations belong to two classes. We’ll color one blue and the other orange. With enough points, they form two clouds.</p><p>We want to keep one number per observation instead of two. Choose a line and drop a perpendicular onto it from each point. The position of the projection along the line will be our new number.</p><p>Imagine the clouds casting shadows onto a long, thin ruler. Rotate the ruler and the shadows change.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kau0Vq0SMLRgOi3GNeMdCw.png" /></figure><p><em>Figure 1. In the upper panels, dashed segments connect observations to their projections onto the line. The larger markers on the line are the projected points. Both panels show the same subset of observations to keep the picture readable. The lower panels show the coordinate distributions for all observations, with the origin shifted to the overall sample mean.</em></p><p>Look at the lower panels. On the vertical axis, the classes cast almost the same shadow. Along the tilted line, they are easier to distinguish: each shadow is narrower relative to the distance between their centers.</p><p>Nobody moved the original points. We only chose which coordinate to measure.</p><p>We’ll look for <strong>a direction along which the classes are easy to distinguish after projection</strong>. For now, we’re judging by eye. To choose a direction algorithmically, we’ll need a number that measures how well it separates the classes.</p><p>The colors do more than decorate the picture. LDA knows which class each training point belongs to and uses those labels to choose the projection. Without them, we couldn’t separate variation within a class from differences between classes.</p><h3>2. Turning a Point into One Number</h3><p>Take a point with coordinates x=(3,4)ᵀ. We can represent the same pair of numbers as <strong>a vector from the origin to that point</strong>: move 3 units horizontally and 4 vertically. In the figure below, x is drawn as this arrow. The observation stays in the same place; the arrow simply makes its position relative to the origin visible.</p><p>For a horizontal line, the new number is 3. For a vertical line, it’s 4. What about a tilted line?</p><p>Describe the direction with a unit vector w=(w₁,w₂)ᵀ. “Unit” means it has length 1. The dot product gives the point’s coordinate along that line:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wPEdyxHxNUer1ydIk5Aq-A.png" /></figure><p>The right-hand side is a <strong>linear combination of features</strong>. Multiply x₁ and x₂ by the weights w₁ and w₂, then add. The dot product is a shorter way to write the same sum.</p><p>The superscript T means transpose: a column vector becomes a row vector, and the product gives a single number.</p><p>For the horizontal axis, w=(1,0)ᵀ, so z=3. For the vertical axis, w=(0,1)ᵀ, so z=4. For a tilted line, let’s choose w=(2,1)ᵀ/√5.</p><p>Now multiply <strong>matching coordinates of x and w</strong>: the observation’s first coordinate, 3, by the first weight, 2/√5; its second coordinate, 4, by the second weight, 1/√5. Then add the two results:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U8fhg1UPH6DH056oTXbJGw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*89kVW7X4k1zZEcdLSsjifg.png" /></figure><p><em>Figure 2. The blue arrow x shows the original observation’s position: it starts at the origin and ends at (3,4). The black unit arrow w specifies the projection direction. The green segment runs from the origin to the projected point (4,2) and has length z≈4.47. The dashed segment from the tip of x meets the line at a right angle.</em></p><p>It’s easy to confuse the number with the point here. The number z tells us <strong>how far to travel along the line</strong>, and the unit vector w tells us <strong>in which direction</strong>. One w is a step of length 1. Take z such steps and we reach the projected point: z · w = (wᵀ · x) · w.</p><p>In our example, its coordinates are:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4tGMFSMrXKkYykBbBjJ1ig.png" /></figure><p>We’ve found a point on the line. If z is negative, we travel in the opposite direction.</p><p>What if w isn’t a unit vector? Then wᵀ · x is still a linear combination, but its scale also depends on the length of w. In that case, z · w needs an extra normalization to give the orthogonal projection. For LDA, we’ll care about the direction and allow ourselves to choose the scale freely.</p><p>Go back to Figure 1: the lower panels show the values of these linear combinations. For the vertical axis, the weights are (0,1); for the tilted line, both features contribute. LDA looks for weights that make the new coordinate useful for distinguishing classes.</p><p>We need to be careful with the viewing metaphor. Projecting points <strong>onto a horizontal line</strong> keeps x₁ and discards x₂. But if we look at the plane <strong>from the side, along the horizontal direction</strong>, horizontal distances disappear into depth; what remains visible is the vertical position. To get a horizontal “shadow,” we must look perpendicular to the horizontal line. We’ll say “project onto the line” from here on, so it’s clear which coordinate we keep.</p><h3>3. Distant Centers Aren’t Enough</h3><p>Our first idea: choose the direction along which the class means end up as far apart as possible. Let’s test it with six numbers.</p><p>Suppose projection gives us these two classes:</p><pre>Class A: 1, 2, 3<br>Class B: 8, 9, 10</pre><p>Their means are 2 and 9, a distance of 7 apart. A threshold anywhere between 3 and 8 easily separates all six observations.</p><p>Now change the data:</p><pre>Class A: −5, 2, 9<br>Class B: 2, 9, 16</pre><p>The means are still 2 and 9. The distance is still 7. But the classes now share some values, so a single threshold cannot separate these observations perfectly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0pgcrZ0RDhhe1-hPwlXVBg.png" /></figure><p><em>Figure 3. The dashed lines haven’t moved, but the classes have become harder to distinguish. The translucent segments show the range of the points; the criterion below uses sums of squared deviations, not ranges.</em></p><p>The distance between the means stayed the same, yet separating the classes became harder. The difference is in their width. Looking only at the centers misses it.</p><p>We need two quantities: <strong>the distance between centers</strong> and <strong>the spread of observations around their own class centers</strong>.</p><p>Choose a line with direction w and project the points onto it. Let mᵢ be the mean of the new coordinate in class i. It equals the projection of the original class mean: mᵢ = wᵀ · μᵢ. Now sum the squared deviations from it:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KA-U-oxsTeHOhhw2dZardA.png" /></figure><p>where Dᵢ is the set of observations in class i.</p><p>This is just a sum: the farther an observation is from its class center, the more it contributes. Squaring prevents positive and negative deviations from canceling out.</p><p>Absolute values would prevent cancellation too. We could build a measure of spread with them, but that would lead to a different method. Fisher’s criterion uses squares: they connect to variance and let us write the calculation in matrix form. Larger deviations also get more weight. A deviation of 2 contributes 4; a deviation of 4 contributes 16. There is a tradeoff: outliers have a particularly strong effect on this measure.</p><p>Let’s combine the two quantities into a score for two classes:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rAIp47_wXwzlNwiAEXqY8w.png" /></figure><p>The numerator is the squared distance between the centers. The denominator is the total within-class scatter. For now, assume the denominator is positive.</p><p>For the compact example, s₁+s₂=4, so the score is 49/4=12.25. For the wider example, s₁+s₂=196, giving 49/196=0.25.</p><p>The score caught what distance alone missed: with the same means, compact classes are easier to separate. This is <strong>Fisher’s two-class criterion</strong>. Later, we’ll write its matrix form for multiple classes. The numerator will use a slightly different normalization, but for two classes the best direction will stay the same.</p><p>The largest distance between centers and the smallest spread might occur along different lines. We want a compromise: the best <strong>ratio</strong> of one to the other.</p><h3>4. Direction Matters More Than Arrow Length</h3><p>Why a ratio? Couldn’t we take the squared distance and subtract the spread instead? For example, we could try to maximize:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aC41tgst5xjM5aC4W3EPmA.png" /></figure><p>Replace our vector w with 10 · w. The new coordinates grow tenfold, as does the distance between their means. The squared distance and sums of squared deviations grow a hundredfold.</p><p>The classes haven’t become easier to distinguish. We’ve merely changed the scale of the new axis, as if we switched from meters to decimeters.</p><p>In the ratio, the scale cancels:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0Bf1gdysCGHK84NDjr0a-A.png" /></figure><p>We lengthened the arrow, but the score stayed the same. It depends only on the direction of the line. We can even change the sign of w: the axis reverses, but class separation stays the same.</p><p>The difference behaves otherwise. Write the squared distance as B and the scatter as U. After rescaling:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aMTdFlQguQyWP-T4krnP2Q.png" /></figure><p>If the original difference is positive, we can make it arbitrarily large simply by lengthening w. The direction hasn’t changed, yet its “quality” keeps improving. Without a constraint on scale, this score won’t do.</p><p>We could use a difference if we constrained the scale of w separately, but that would be a different optimization problem. Fisher’s ratio already compares the distance between centers with class width and stays unchanged when we lengthen the arrow.</p><p>Now we need a way to compute the numerator and denominator for any line. To do that, we’ll collect the information about spread into matrices.</p><h3>5. Turning a Cloud’s Shape into a Matrix</h3><p>Let’s start with <strong>variance</strong>. For one feature, it measures how widely values are spread around their mean. We average the squared deviations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VEuOHd5yRmRWRgpRcSIcdA.png" /></figure><p>Here 𝔼 denotes expectation; its sample counterpart is an average over observations. The more the values spread around their center, the larger the variance. If all values are identical, it is zero.</p><p>Covariance answers another question: <strong>how do two features deviate from their means together</strong>?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0bPGvmhiJxDt9Cy5iyOYbw.png" /></figure><p>In this formula, μ₁ and μ₂ are the means of the first and second features, not the centers of two classes. For the moment, we’re looking at a single cloud of points.</p><p>When both features deviate from their means in the same direction, their product is positive. When they deviate in opposite directions, it is negative. If the positive contributions outweigh the negative ones in the average, covariance is positive; if the negative contributions outweigh them, it is negative. If they cancel, it is zero. That doesn’t mean the features have no relationship at all: their dependence might be nonlinear.</p><p>Our new coordinate is Z = w₁ · X₁ + w₂ · X₂. Expanding its squared deviation from the mean gives:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oH6FumMkZ2vM-GWvRPaxIg.png" /></figure><p>The first and last terms account for each feature’s spread. The middle term accounts for how they change together. In our diagonal clouds, the two features tend to increase together, so covariance is positive. Adding them with positive weights reinforces those shared changes. Subtracting one feature from the other can cancel some of them. A combination like X₁−X₂ can therefore make a class more compact while preserving its difference from another class.</p><p>Collect the variances and covariances in a matrix:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rD5VhFAFWyL8IezjSiL0JQ.png" /></figure><p>Let’s check what happens when we multiply wᵀ · Σ · w. Denote the matrix entries by σ₁₁, σ₁₂, and σ₂₂. The two off-diagonal entries are equal: σ₁₂=σ₂₁.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*SGHhZkZJ1lPs0mHuyfiRLA.png" /></figure><p>We get exactly the same three terms. The idea is the same for a hundred features, but writing out every pairwise covariance by hand would be tedious.</p><p>The expression wᵀ · Σ · w is called a <strong>quadratic form</strong>. We already know what it means here: the variance of the new coordinate after projection onto w. Compute the matrix once, then try different directions. I’ll leave the derivation using expectation in Appendix A.</p><h4>What an Outer Product Stores</h4><p>Let v=x−μᵢ be an observation’s deviation from the mean of class i, <strong>in the original space, before projection</strong>. For two features:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QGA87ZXKP3I6lFgTRtAuyg.png" /></figure><p>The diagonal contains squared deviations for the individual features: v₁² and v₂². Off the diagonal is their product, v₁ · v₂. Its sign tells us whether both features deviated in the same direction from their means or in opposite directions. If both deviations are large, so is the magnitude of the product. The two off-diagonal entries match because the matrix is symmetric.</p><p>For example, suppose an observation is 2 units away from the class mean along the first feature and 3 along the second. Then:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UgnOaWcxXTCml20KrOxQCA.png" /></figure><p>This is the contribution of <strong>one observation</strong>, not yet the class’s variances and covariances. To obtain those, average these matrices over the observations in the class:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jmEVrODATvqZLaJt-X_zWA.png" /></figure><p>Here we use covariance with division by nᵢ. Without that division, we get the scatter matrix Sᵢ = nᵢ · Σᵢ. So outer products connect directly to the familiar Σ: their average is the sample covariance matrix.</p><p>We could have kept only the observation’s distance from its class center. But then we’d lose information about which axes it deviated along. The four entries preserve the squared deviations along both axes and how they combine. This lets us obtain the squared projection of the deviation onto any line:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2Tc9CdB6-_fSb-cUFEF9YA.png" /></figure><p>By comparison, the dot product vᵀ · v = 4 + 9 = 13 would keep only the squared length of the deviation. We’d lose the directional information needed for our later calculations.</p><p>This matrix doesn’t remember the cloud’s entire shape. One continuous cloud and several separate groups can have identical means and covariances. For now, we need something more modest: a way to compute the squared spread along any line we choose.</p><h3>6. Two Kinds of Spread: Within and Between Classes</h3><p>A point has two reference centers: its own class mean and the overall sample mean. Deviation from the first tells us about class width. Differences between the class means tell us how the classes are positioned relative to each other.</p><p>Let C be the number of classes, d the number of features, and nᵢ the size of class i. The total number of observations is n = ∑ᵢ nᵢ.</p><p><strong>The mean of class i</strong> is the average of its observations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PSg2l-dOCreCUqhx0KId1A.png" /></figure><p><strong>The overall sample mean</strong> is the average of all observations:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vt6metVuvFB0953vcR8-1g.png" /></figure><p>A large class influences the overall mean more than a small one. That’s why the class means enter the formula with weights nᵢ.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J_MGD8Xdk-_GYPVqIddw2w.png" /></figure><p><em>Figure 4. Left: the original clouds, their means, and arrows for the two kinds of deviations. Middle: each class is shifted as a whole so that its own mean reaches the origin. The cloud shapes remain the same, but their centers now coincide at zero. Right: observations are replaced by their class means. The right panel uses a zoomed-in scale.</em></p><h4>Within-Class Spread</h4><p>Take each observation’s deviation from <strong>its own</strong> class mean and sum the outer products:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-hmnnNkCzPPwSG-I25m4Fg.png" /></figure><p>The two sums mean two steps. Within class i, add the contributions of all its observations: ∑ (x ∈ Dᵢ). Then add the results across classes: ∑ (i = 1,…,C).</p><p>We’ve obtained the <strong>within-class scatter matrix</strong>. The subscript W comes from “within.”</p><p>Move an entire class without changing its shape, and this matrix stays the same. Its mean moves along with its observations, so the deviations x−μᵢ don’t change.</p><p>What happens after projection?</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3zNtuqI4RimoSbkPipDF0g.png" /></figure><p>On the right is the sum of squared deviations we started with, now computed for our chosen direction w. The matrix expression lets us obtain it without going through all the points again.</p><h4>Between-Class Spread</h4><p>Now temporarily replace each observation with its class mean. The shapes of the clouds disappear, but the differences between their centers remain.</p><p>Measure how these means deviate from the overall mean:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pRic8AP3yeCsMIfSCBfz9g.png" /></figure><p>This is the <strong>between-class scatter matrix</strong>. The subscript B comes from “between.”</p><p>The factor nᵢ comes from our replacement. All nᵢ observations of a class now sit at its mean, so the same deviation from the overall mean must count nᵢ times.</p><p>In S_W, the inner sum already went through every observation. Multiplying by nᵢ again would count every contribution too many times. In S_B, we’ve replaced identical repeated terms with a multiplier. We don’t divide by the total number of observations n here: scatter matrices store sums, not averages.</p><p>After projection:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tlIKWq5aWm-SPvq5ARRbeQ.png" /></figure><p>This is the weighted scatter of the projected class means around the projected overall mean.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tf4C9I1aJOJuoqOlSW4oaA.png" /></figure><p><em>Figure 5. Left: the structure captured by S_W, with each class spread around its own mean. Right: the ingredients of S_B, namely the class means and the number of observations each mean represents. The star marks the overall mean.</em></p><h4>Putting the Criterion Together</h4><p>Substitute both kinds of scatter into <strong>Fisher’s criterion</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F7l8l_0x-JXSfnyHnpx2jg.png" /></figure><p>The numerator measures differences between centers; the denominator measures class width. Both are computed after projection onto the same line. The larger the ratio, the farther apart the centers are relative to the spread around them.</p><p>With four features, both matrices are 4×4, whether we have a hundred observations or a million. In general, their size is d× d. The number of observations affects their entries, not their dimensions.</p><h4>What Makes Up the Total Spread</h4><p>What if we measure the spread of all observations around the overall mean, ignoring class labels? Call that matrix S_T. It splits into two familiar parts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uviVeDdTVAgTy9qRNw2CuA.png" /></figure><p>Observations vary for two reasons: the classes occupy different positions, and there is spread within each class. The identity adds these two contributions. We’ll use it to compare LDA with PCA; the proof is in Appendix B.</p><h3>7. Rotating the Line to Find the Maximum</h3><p>In two dimensions, a single angle specifies a direction:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*G0l7ytgLTOQja8QmCAYlYw.png" /></figure><p>This is a unit vector. Its horizontal coordinate is cos θ and its vertical coordinate is sin θ. On the unit circle, these give the tip of an arrow of length 1:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jT2FrJ8LJdud4U08hG5hrQ.png" /></figure><p><em>Figure 6. Rotating the vector changes the two feature weights. The arrow’s length stays equal to 1.</em></p><p>Change the angle, compute J(w), and we get an ordinary function plot.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5QZ8C2ewG2T4WnDXTHjkIA.png" /></figure><p><em>Figure 7. The maximum corresponds to the direction where between-class scatter is large relative to within-class scatter. Every panel uses the same points as Figure 1.</em></p><p>The highest point on the curve gives the direction we want. The vertical axis shows Fisher’s criterion: the ratio of between-class to within-class scatter. It isn’t a probability or accuracy, so its values need not lie between 0 and 1.</p><p>Opposite arrows define the same line. The new coordinate changes sign, but the quality of separation stays the same. We therefore only need to examine angles from 0 to 180 degrees.</p><p>Searching over angles is convenient in the plane. With a hundred features, one angle no longer specifies a direction. Let’s find the maximum without that search.</p><h3>8. From a Constraint to Eigenvectors</h3><p>The task hasn’t changed: find the direction with the largest J(w). This time, we’ll work with the coefficients w instead of rotating a line.</p><p>For this derivation, we need S_W to be positive definite: within-class scatter must be positive along every nonzero direction. The scale of w doesn’t affect the criterion, so choose it such that:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*da6bbGkfjmcwOl7dE3fV-A.png" /></figure><p>Just divide a nonzero w by √(wᵀ · S_W · w). Its direction stays the same, and the denominator becomes 1.</p><p>This makes the problem easier: to maximize <strong>Fisher’s criterion</strong> J(w), we only need to maximize the numerator. We must keep the constraint, though:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Kt4UksHRQ9zWF_1XhxtLUA.png" /></figure><p>In the two-dimensional space of coefficients w, the constraint defines an ellipse. Each point on it is a set of weights giving within-class scatter equal to 1. We need to move along that ellipse and find the largest numerator. With more features, the ellipse becomes an ellipsoid.</p><h4>Why We Need a Lagrange Multiplier</h4><p>Before taking derivatives, let’s understand the constraint itself. Suppose we want to maximize f(q), but only points where g(q)=0 are allowed. For now, q denotes a set of variables; we’ll replace it with w shortly.</p><p>Imagine walking on a mountainside, with one rule: we cannot leave a closed path. The <strong>gradient</strong> ∇ f points in the direction of the fastest increase in height. It might point away from the path, while we have to stay on it.</p><p>At the highest point of the path, a step along it no longer increases height to first order. The height gradient points across the path. The constraint gradient ∇ g is also perpendicular to the curve g=0. So these two arrows are parallel:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cdV1IJg8ncID-3UsBIHgow.png" /></figure><p>The number λ tells us how much to scale the second arrow to match the first. In our problem, a positive maximum gives λ&gt;0, so the arrows point in the same direction. In a general Lagrange multiplier problem, they can also point in opposite directions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0vB62qiiXye8hRZ6xArNqg.png" /></figure><p><em>Figure 8. Left: the translucent surface shows height, the dark curve is the allowed path, and P is its maximum. A vertical dotted line connects P to its projection in the plane of the variables. Right: the same gradients viewed from above. The blue arrow is the objective gradient; the orange arrow is the constraint gradient. They start at the same point, point in the same direction, and are perpendicular to the path’s tangent. These gradients act in the two variables q₁ and q₂; the vertical axis of the 3D plot shows the function value.</em></p><p>If we now look only at height as we move along the path, we get an ordinary plot against angle:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wPMNhlGGJfmJNq_uIw91XQ.png" /></figure><p><em>Figure 9. The angle is measured from the positive q₁ axis, and the plot shows half of the closed path. At P, height is maximal and the tangent to the graph is horizontal: to first order, a step along the path doesn’t change height.</em></p><p>We’ve reached the highest point on the path, but not necessarily the summit of the whole mountain. The gradient ∇ f itself can therefore be nonzero. What vanishes is the rate of change <strong>along allowed movements</strong>. Move everything to the left:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n5PFdPTgZhKTAH--sE-1aQ.png" /></figure><p>This is the derivative with respect to q of the following auxiliary function, the Lagrangian:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dwPG-r0hY2RaW4RnBhrLZg.png" /></figure><p>Taking the derivative with respect to λ gives −g(q)=0, the original constraint. The Lagrangian lets us express both requirements: stay on the path and find a point where there is no first-order increase along it.</p><p>Back to LDA: f(w) = wᵀ · S_B · w and g(w) = wᵀ · S_W · w − 1. Substitute them:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IJWr7NZpEENWWrG0bM4Akw.png" /></figure><p>For allowed values of w, the expression in parentheses is zero. The number λ scales the constraint gradient so that it can match the numerator’s gradient.</p><h4>Differentiating a Quadratic Form</h4><p>Take a symmetric 2×2 matrix B. Then:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Pd9NKXA50UZA4hFRpuIaLA.png" /></figure><p>First differentiate with respect to w₁, treating w₂ as constant; then do the reverse. Put the two derivatives together to obtain the gradient:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Z_JohJO-Elfgmj4ct8PMWQ.png" /></figure><p>The rule is the same with more features. The two symmetric quadratic forms in the Lagrangian therefore give:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0OxIv91UFt6mqK7E7by6IA.png" /></figure><p>We’re setting the <strong>gradient of the Lagrangian</strong> to zero: the two arrows cancel. Divide by 2:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*duMvI8n8bSXgTNxbtCrucQ.png" /></figure><h4>Where Eigenvectors Come In</h4><p>Here’s where eigenvectors appear. What kind of arrows are they? A matrix can stretch and shrink vectors, and it can change their directions. But some nonzero arrows stay on their original line after the transformation. These are <strong>eigenvectors</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*avohCIvrCjqzWeV0A6ZEdQ.png" /></figure><p>The <strong>eigenvalue</strong> λ tells us what happened to such an arrow. For example, the matrix diag(2,1) doubles a horizontal arrow and leaves a vertical arrow unchanged. Their eigenvalues are 2 and 1. A tilted arrow turns: its horizontal component grows while its vertical component stays the same.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xqYvtcUW06U_5Fdc0DRVOg.png" /></figure><p><em>Figure 10. The dashed arrow is the original vector, and the solid arrow is the transformed vector. An eigenvector stays on its original line; a negative eigenvalue could reverse the arrow.</em></p><p>Our equation S_B · w = λ · S_W · w compares two transformations of the same arrow. That’s why it’s called a <strong>generalized eigenvalue problem</strong>. If S_W is invertible, we can write:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Y-gwtM3c9mNHrA0oPgAO2w.png" /></figure><p>So w is an eigenvector of the transformation M = S_W⁻¹ · S_B. We don’t need to invert the matrix separately in code: a solver can work directly with the pair (S_B,S_W).</p><h4>Which Eigenvalue Should We Choose?</h4><p>Multiply the generalized equation on the left by wᵀ:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*00w-D7b5g_uOSzDWWXNu_Q.png" /></figure><p>Now λ has a meaning specific to LDA: it is <strong>the value of Fisher’s criterion</strong> for the corresponding direction. Choose the largest one.</p><p>Could there be an even better direction between the ones we found? For symmetric scatter matrices and positive definite S_W, there isn’t: the largest eigenvalue gives the global maximum. Mixing eigenvector directions produces a weighted average of their scores. An average cannot exceed the largest value being averaged.</p><p>In the plane, we’d find the same peak of J(θ) as in Section 7. Eigenvectors let us find it for a hundred features too.</p><h4>What If We Need Several New Coordinates?</h4><p>So far, each observation has received one number. We could get two: z₁ = w₁ᵀ · x and z₂ = w₂ᵀ · x. Each coordinate uses its own combination of features. Then we can draw the observations as points in a plane again.</p><p>Instead of a single vector, use a matrix W, with a separate direction in each column:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cp_XCkEVn-y4ezhRs3zvZQ.png" /></figure><p>Here wⱼ is the whole vector for the j-th direction, not an individual feature weight. We obtain k new coordinates for each observation at once.</p><p>If we simply run the maximization again, it will return the same best direction. We don’t need several copies of one feature. Instead, require:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TYL2-fFDAVvPiKWJetNlQw.png" /></figure><p>This is the counterpart of wᵀ · S_W · w = 1 for several coordinates. The diagonal entries impose wⱼᵀ · S_W · wⱼ = 1: all coordinates are normalized to unit scatter. Off the diagonal, wⱼᵀ · S_W · wₗ = 0 for j≠ l: the within-class deviations of different coordinates are uncorrelated. Being uncorrelated doesn’t imply statistical independence. The directions themselves need not be perpendicular in the original space.</p><p>We maximize:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vw6CflU2r-XOi33BHWG0MA.png" /></figure><p>The trace, written tr, sums the diagonal entries. Each equals wⱼᵀ · S_B · wⱼ, the between-class scatter along one new axis. So the trace sums the scatter along all selected axes. Geometrically, this is the weighted sum of squared distances from class means to the overall mean in the new space. The off-diagonal entries describe how coordinates vary together; they don’t enter the squared distance.</p><p>The solution consists of the k leading generalized eigenvectors. They select strong directions without repeating the same one.</p><p>Incidentally, if the numerator is positive, we could choose the normalization wᵀ · S_B · w = 1 and minimize the denominator. But wᵀ · S_W · w = 1 is easier to connect to our intuition: fix the allowed class spread and seek the greatest difference between centers.</p><h3>9. Why LDA Has at Most C − 1 Components</h3><p>Recall that <strong>an LDA component is one new numerical feature</strong>, a linear combination of the original features. One component gives each observation one number; two components give it two new coordinates.</p><p><strong>The limit C−1 comes from the number of class means, not from the act of projection itself.</strong></p><p>Imagine two classes in a space with 100 features. There is one vector between their means:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5Z_hRlc0sIq4VOvTCLlvBQ.png" /></figure><p>It has 100 coordinates, but it is <strong>one difference vector</strong>. LDA accounts for within-class spread and finds one best coordinate for expressing this difference.</p><p>We could choose a subspace of dimension 99, which would already reduce dimensionality. But it wouldn’t create 99 independent differences between two centers. There are still two centers, and one difference between them.</p><p>For three classes, we can take two vectors:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jatsP4viPO6Sj-aoGfZD_w.png" /></figure><p>Every other difference between class means can be expressed using these two. For example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xq2SmsKRtZNP9xPpNFoMaQ.png" /></figure><p>So there are at most two independent differences, whether the original observations had 3, 100, or 1000 features.</p><p>For C classes, pick one mean as a reference and draw C−1 vectors to the others. Every pairwise difference between class means can be expressed using these vectors. There can therefore be at most C−1 independent differences.</p><p>The number of new independent coordinates also cannot exceed the number of original features d. We get two limits:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5sIGiaSTTFwCXCTr_KvZ9A.png" /></figure><p>Here k is the number of LDA components with positive eigenvalues: the independent discriminant coordinates selected by LDA. It doesn’t count every possible line. We can invent infinitely many projection directions.</p><p>The actual number can be smaller. Three class means on one line, for example, give only one independent direction of differences. If all class means coincide, between-class scatter is zero. As in the main derivation, we’re assuming S_W is positive definite.</p><h3>10. PCA and LDA: Which Spread Do We Want to Keep?</h3><p>Both methods can give an observation fewer coordinates, but they choose those coordinates for different purposes. <strong>PCA tries to preserve the data’s overall variation.</strong> <strong>LDA uses known class labels</strong>, so it aims to preserve differences between classes.</p><p>LDA is also used as a classifier: it builds a rule for choosing the class of a new observation. So far, we’ve worked through the search for discriminant coordinates. This is connected to classification, but doesn’t yet specify a decision rule.</p><p>PCA doesn’t use class labels. It looks at total variation and seeks the direction where it is greatest:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*vNoh-72SRsrLHKeNOz4jkA.png" /></figure><p>Without the length constraint, we could increase variance simply by lengthening w. For several perpendicular components, PCA preserves the greatest total variation. This is equivalent to another goal: reconstruct the original points as accurately as possible from fewer coordinates, measuring error with squared distances.</p><p>LDA uses the classes and maximizes our familiar ratio:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QfWwWxalOVgI4uL3VPvMdQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AYMgB-WMB6j4nUH_LG9Jig.png" /></figure><p><em>Figure 11. The points, colors, and original coordinate scales are identical. The lower panels show projections onto the selected directions.</em></p><p>In the figure, PCA chooses a direction along the clouds’ long axis. The spread there is large, so the method has done its job. But the colors are mixed in the lower panel: much of the variation it preserved comes from changes within classes.</p><p>LDA measures how far the centers have separated relative to the width of each class. Large spread on its own promises it nothing.</p><p>Recall S_T=S_W+S_B. PCA evaluates the sum. LDA evaluates the ratio of its two parts.</p><p>Here Fisher’s criterion is approximately 0.047 along the first PCA component and 1.216 along the LDA direction. LDA wins by this criterion, but we chose that criterion for its task. PCA never tried to separate the colors.</p><p>The choice depends on what we want to preserve. For overall variation, PCA’s objective fits. For differences between known classes, LDA’s objective fits. We still need to check how useful the chosen method is on our data.</p><h3>11. Checking Our Understanding with Code</h3><p>Let’s build LDA from the pieces we’ve just worked through. We’ll use Iris: 150 flowers, four measurements, and three classes. That gives us at most two LDA components.</p><pre>import numpy as np<br>from scipy.linalg import eigh<br>from sklearn.datasets import load_iris<br><br># Each row of X is a flower; each column is one of four measurements.<br># y contains the known flower classes.<br>X, y = load_iris(return_X_y=True)<br>d = X.shape[1] # Number of original features.<br>mean = X.mean(axis=0) # Overall mean: the mean of each column.<br><br># Both matrices describe directions in the space of d features.<br>S_W = np.zeros((d, d))<br>S_B = np.zeros((d, d))<br><br>for label in np.unique(y):<br>    X_i = X[y == label] # Select observations from one class.<br>    mean_i = X_i.mean(axis=0) # Find the class mean.<br><br>    # Deviations from the class mean: contribution to S_W.<br>    centered = X_i - mean_i<br>    S_W += centered.T @ centered<br><br>    # Class mean&#39;s deviation from the overall mean, weighted by n_i.<br>    delta = mean_i - mean<br>    S_B += len(X_i) * np.outer(delta, delta)<br><br># Solve S_B w = lambda S_W w; S_W is positive definite for Iris.<br>values, vectors = eigh(S_B, S_W)<br>order = np.argsort(values)[::-1] # Larger criterion values first.<br>W = vectors[:, order[:2]] # Two directions, each with four weights.<br><br># Result: two new coordinates for each of the 150 observations.<br>Z = (X - mean) @ W<br>print(X.shape, W.shape, Z.shape)<br># (150, 4) (4, 2) (150, 2)</pre><p>The result we wanted is in <strong>Z, an array of shape </strong><strong>(150, 2)</strong>. Each flower now has two numbers instead of four measurements. We can plot it in a plane or pass the new features to another classifier. To evaluate performance on new flowers, we must fit the whole chain on the training set. We&#39;ll return to that below.</p><p>The line centered.T @ centered sums the outer products of deviations for all observations in a class. And np.outer(delta, delta) builds the outer product for one class mean. For example, delta = [2, 3] gives [[4, 6], [6, 9]], the familiar matrix from Section 5. This is how the code builds S_W and S_B.</p><p>We subtracted the overall mean before projection to place the new origin there. This shift doesn’t change differences between classes or their spreads.</p><p>We use <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html">scipy.linalg.eigh</a> to solve the problem. It accepts symmetric matrices and solves the generalized problem directly; the second matrix must be positive definite. Eigenvalues are returned in ascending order, so we reverse the order.</p><p>We could compute S_W⁻¹ · S_B separately, but the code doesn’t need to. Although both original matrices are symmetric, their product generally isn’t. The eigh solver takes the pair (S_B,S_W) and works with the original problem.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*VhnVoMoZA7YGbhIKdvGObQ.png" /></figure><p><em>Figure 12. Reduction from four dimensions to two: LD1 and LD2 are the linear combinations of features we found. Notice how the classes sit in the new space: setosa separates well, while the other two partially overlap. The directions were fitted on the entire Iris dataset; this picture cannot measure performance on new flowers.</em></p><h4>Comparing with scikit-learn</h4><p>The ready-made implementation handles the same steps for us:</p><pre>from sklearn.discriminant_analysis import LinearDiscriminantAnalysis<br><br># The same two directions, empirical class proportions, no regularization.<br>lda = LinearDiscriminantAnalysis(n_components=2, solver=&quot;eigen&quot;)<br>Z_sklearn = lda.fit_transform(X, y)</pre><p>With matching class weights and no regularization, the directions from both implementations span the same subspace. The numbers in Z, however, need not match. One implementation might give [-2, 0, 3], the other [4, 0, -6]. The axis has flipped and stretched by a factor of two, while separation stays the same. Different coordinates don&#39;t necessarily mean a bug :) With several coordinates, we could also get a different basis for the same subspace.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZumYW2zQb8jiET5eCiYSGw.png" /></figure><p><em>Figure 13. For a fair visual comparison, both implementations’ directions are normalized using Wᵀ · S_W · W = I and aligned in sign; the same overall mean is subtracted. The leading eigenvalues for Iris are distinct, so matching the axes requires no additional rotation.</em></p><p>Here’s a check that compares the subspaces of directions themselves and doesn’t depend on column scale or sign:</p><pre>from scipy.linalg import subspace_angles<br><br># Columns of both matrices span subspaces in the original four dimensions.<br>angles = subspace_angles(W, lda.scalings_[:,:2])<br>print(&quot;Maximum angle, radians:&quot;, angles.max())<br>assert angles.max() &lt; 1e-12</pre><p>An angle close to zero means the subspaces agree to numerical precision. In our run, the largest angle is less than 10⁻¹² radians. The function <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.subspace_angles.html">subspace_angles</a> compares subspaces spanned by matrix columns. It doesn&#39;t directly compare the values of the new coordinates.</p><h4>Where the Method Can Struggle</h4><p><strong>Nonlinear structure.</strong> Look at two concentric rings:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*P0vz95x4ZhoouV3ll8F4FA.png" /></figure><p><em>Figure 14. The class means coincide, but the radii differ. Distance from the center would be a useful new feature for separating them.</em></p><p>When the means coincide, S_B=0, so Fisher’s criterion</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*QimcfRFe6hyhs0XATv6QgA.png" /></figure><p>is zero along any direction with a positive denominator. The rings are easy to distinguish by distance from the center, but LDA finds no difference in their means here. The points in the figure are placed symmetrically, so the means coincide exactly. In a random sample, they could be slightly different.</p><p><strong>A singular scatter matrix.</strong> With many features and few observations, S_W can be singular. There is then a nonzero direction along which every observation’s within-class deviation is zero: wᵀ · S_W · w = 0. This also happens when one feature exactly duplicates another. The matrix has no ordinary inverse, and our call to eigh won&#39;t work with it: the second matrix must be positive definite. Approaches based on SVD, regularization, or shrinkage are used for these problems. The options are covered in the <a href="https://scikit-learn.org/stable/modules/lda_qda.html#shrinkage-and-covariance-estimator">LDA documentation</a>.</p><p><strong>A high score doesn’t guarantee good classification.</strong> Means and squared spread don’t describe every detail of a distribution. Outliers, class shapes, and the chosen decision rule all affect performance. A high J doesn’t replace checking accuracy on new observations.</p><h4>Where the LDA Classifier Begins</h4><p>We have new coordinates, but we don’t yet have an answer to which class a new observation belongs to. For that, we need a decision rule.</p><p>The LDA classifier assumes that classes follow multivariate normal distributions. In the plane, these are our familiar elliptical clouds: different centers but a shared covariance, meaning the ellipses have the same sizes and orientations. For a new point, the model compares how likely it is to belong to each class. The calculation also includes prior probabilities: how often we expect to see each class before looking at the observation’s features.</p><p>Real data doesn’t have to fit these assumptions exactly. LDA is worth trying when the boundary is roughly linear, class shapes and spreads are comparable, and there is enough data to estimate the shared covariance. It also makes a useful first model to compare against. Then we check performance on held-out data.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hpuwyYCSaJ-j2P-aCld9Bw.png" /></figure><p><em>Figure 15. The vector defines the axis of the useful coordinate; the line is the boundary between class decisions. These are different objects: in two-class LDA, the projection direction is normal to the decision boundary. The background shows predicted classes from a model with shared covariance and equal class priors.</em></p><p>For this evaluation, fit LDA <strong>only on the training data</strong>, separately within each split. Otherwise, the projection already knows something about the test labels and performance will look too optimistic. In scikit-learn, it’s convenient to put the transformation in a Pipeline.</p><h3>Back to the First Picture</h3><p>We started with two clouds and a question: where should the new axis point?</p><p>We wanted the centers as far apart as possible relative to class width. Simply stretching the new axis shouldn’t improve the score. Those requirements gave us Fisher’s criterion.</p><p>The matrices let us compute spread for any direction. Eigenvectors let us find the maximum without trying every line. Each step now has a reason.</p><p>Look at Figure 1 again. Why is the tilted line more useful than the vertical one? If you can explain it through the centers, the cloud widths, and how the features change together, writing this article was worth it :)</p><h3>Appendix A. Where the Variance of a Projection Comes From</h3><p>Let X be a random vector with mean μ and covariance matrix Σ. For a fixed vector w, linearity of expectation gives 𝔼[wᵀ · X] = wᵀ · μ.</p><p>By the definition of variance:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zt6lpN-tR8XJI1k5OpR-Ww.png" /></figure><p>In the second line, we rewrote the square of a scalar as a product. In the third, we pulled the fixed w outside the expectation. What remains inside is the definition of the covariance matrix, which gives Σ in the last line.</p><p>The two w’s on the outside came from squaring the linear combination. That’s why the matrix sits between them.</p><h3>Appendix B. Why Total Scatter Splits into Two Parts</h3><p>For an observation in class i, write:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dLPTZvGwGLQTYD8LcZXWgw.png" /></figure><p>The first term is the observation’s deviation from its own class mean. The second is the class mean’s deviation from the overall mean.</p><p>Let a=x−μᵢ and b=μᵢ−μ. Expand the outer product:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WdbCFGNcbk_KuGz_awLLhw.png" /></figure><p>Summing the first term over classes and observations gives:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Xp0B0IaTgpFLPEH_qL4XgA.png" /></figure><p>The last term gives S_B, because b is the same for every observation within a class:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*EBacXAyNMOss9FIHJ7SCKg.png" /></figure><p>The two cross terms vanish because, within each class,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WQNXl3VgNHlxbgyuoec7lw.png" /></figure><p>Only S_W and S_B remain, so S_T=S_W+S_B. After projection, the identity has the same meaning: the total sum of squared deviations of the new coordinate consists of spread within classes and spread between their means.</p><h3>Materials Behind the Article</h3><p>The running example uses one synthetic sample: two classes of 180 observations each, generated with numpy.random.default_rng and seed 17. The specified means are (−1,0)ᵀ and (1,0)ᵀ, with shared covariance [[4, 3.6], [3.6, 4]]. The means and matrices used to find the directions were estimated from the generated points; they need not exactly match the generator&#39;s parameters.</p><p>Further reading: <a href="https://scikit-learn.org/stable/modules/lda_qda.html">scikit-learn’s mathematical formulation of LDA and its connection to classification</a> and <a href="https://docs.scipy.org/doc/scipy/reference/generated/scipy.linalg.eigh.html">SciPy’s documentation for the generalized symmetric eigensolver</a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d776e1375c8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>