<?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 Patrick Luboobi on Medium]]></title>
        <description><![CDATA[Stories by Patrick Luboobi on Medium]]></description>
        <link>https://medium.com/@patricklu2010?source=rss-7e7b1ac45b8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*tZMISz2Cz-FRxzLWyU8vlg.jpeg</url>
            <title>Stories by Patrick Luboobi on Medium</title>
            <link>https://medium.com/@patricklu2010?source=rss-7e7b1ac45b8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sat, 05 Dec 2026 18:13:26 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@patricklu2010/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[Foundations of Machine Learning : Singular Value Decomposition (SVD)]]></title>
            <link>https://medium.com/the-andela-way/foundations-of-machine-learning-singular-value-decomposition-svd-162ac796c27d?source=rss-7e7b1ac45b8------2</link>
            <guid isPermaLink="false">https://medium.com/p/162ac796c27d</guid>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[svd]]></category>
            <category><![CDATA[math]]></category>
            <category><![CDATA[linear-algebra]]></category>
            <category><![CDATA[data-science]]></category>
            <dc:creator><![CDATA[Patrick Luboobi]]></dc:creator>
            <pubDate>Mon, 05 Feb 2018 11:13:57 GMT</pubDate>
            <atom:updated>2018-02-13T08:05:32.433Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IZcJKz3761vChU1VFHfzkw.jpeg" /></figure><iframe src="https://cdn.embedly.com/widgets/media.html?url=https%3A%2F%2Fplay.ht%2Farticles%2F162ac796c27d&amp;src=https%3A%2F%2Fplay.ht%2Fembed%2F%3Farticle_url%3Dhttps%3A%2F%2Fmedium.com%2F_p%2Ffoundations-of-machine-learning-singular-value-decomposition-svd-162ac796c27d&amp;type=text%2Fhtml&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;schema=play" width="700" height="185" frameborder="0" scrolling="no"><a href="https://medium.com/media/0b37c16fd30d5c0e71bbad10756d1e57/href">https://medium.com/media/0b37c16fd30d5c0e71bbad10756d1e57/href</a></iframe><p><a href="https://en.wikipedia.org/wiki/Linear_algebra">Linear Algebra</a> is fundamental in many areas of <a href="https://en.wikipedia.org/wiki/Machine_learning">Machine learning</a> and one of the most important concepts is; <a href="https://en.wikipedia.org/wiki/Singular-value_decomposition">Singular Value Decomposition(SVD)</a>. The motivation element behind this article is to get Software Engineers to ameliorate their basic understanding of SVD, and its real-world application.</p><p>Singular Value Decomposition(SVD) is one of the most widely used <a href="https://en.wikipedia.org/wiki/Unsupervised_learning">Unsupervised learning</a> algorithms, that is at the center of many recommendation and Dimensionality reduction systems that are the core of global companies such as Google, Netflix, Facebook, Youtube, and others.</p><p>Specifically, for this article, we shall be looking at a movie recommendation system. But before that, let’s see how SVD works.</p><p>In simple terms, SVD is the factorization of a matrix into 3 matrices. So if we have a matrix <strong>A</strong>, then its SVD is represented by:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*-wHEGA5UHBK4-Bejlbr__A.png" /></figure><blockquote>Where <strong>A</strong> is an m x n matrix, <strong>U</strong> is an (m x m) orthogonal matrix, 𝚺 is an (m x n) nonnegative rectangular diagonal matrix, and <strong>V </strong>is an (n x n) orthogonal matrix.</blockquote><blockquote><strong>U</strong> is also referred to as the left singular vectors, 𝚺 the singular values, and <strong>V</strong> the right singular vectors</blockquote><p>So first let’s see how this comes about and then we’ll look at an example:</p><p>Imagine a circle in two dimensions represented by vectors V1 and V2 undergoing a matrix transformation as illustrated on the cartesian coordinates below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*U1xwDuToC4HgEt-kLTh0fQ.png" /><figcaption>Two Dimensional Circle</figcaption></figure><p><strong>After Matrix Multiplication</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bZd-r1xasUJqozLRoVaSPA.png" /><figcaption>An Ellipse</figcaption></figure><p>From the images above, you can tell that when a matrix multiples a vector, it simply stretches it and then rotates it.</p><p>So if we generalize this from just two dimensions to n-dimensions, the vector space:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/746/1*54z7MZmGxC1C1u9Z21PHVw.png" /></figure><p>after the multiplication, and we have:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/238/1*gj6h9YY5xClp9x6OY9GQjA.png" /></figure><p>representing the space of the individual stretching factors.</p><p>Therefore from this we can write the equation:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/271/1*uimHS-qOlHww3oMZ2zFSHA.png" /></figure><p>which we can write more generally as:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*pSveB7oVq2OzrSspJYioVg.png" /></figure><p>Where <strong>𝚺 </strong>represents the space of all stretching factors(σ’s).</p><p>But for an orthogonal matrix,</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*DyQM8CVwvCo5NfqockmBCQ.png" /></figure><p>Also, note that the product of a matrix and its inverse is the <strong>identity matrix </strong>(An identity matrix is a diagonal matrix with only 1&#39;s). This concept can be represented by the equation below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/225/1*yQwn1hLDNIHDEnjeQESWhQ.png" /></figure><p>Combining the above three equations leads us to the <strong>Reduced Singular Value Decomposition</strong>.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/250/1*-wHEGA5UHBK4-Bejlbr__A.png" /></figure><p>Where <strong>V</strong> is a rotation, 𝚺 a stretching and <strong>U</strong> another rotation. Also, the entries of <strong>U </strong>are the principle axis while 𝚺 are the singular values.</p><p>So this is how you can decompose a matrix into three lower rank matrices.</p><p>Let’s look at a classical application of this. Imagine that we have a matrix A whose columns represent movies and the rows different users. The entries of the matrix are numbers 0 to 5 where 0 means a user does not like a certain movie and 5 means they really like a given movie as illustrated below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/347/1*J3l7Z23t_ZPTwCJFBZpYog.png" /></figure><p>Now imagine that the first 3 columns are the movies Avengers, StarWars and IronMan respectively(Sci-Fi movies). While the last 2 columns are the movies Titanic and Notebook (Romance movies).</p><p>After performing SVD on matrix A we get the matrices U𝚺V as illustrated below(using a tool like or <a href="http://scikit-learn.org/stable/modules/generated/sklearn.decomposition.TruncatedSVD.html">sklearn</a>):</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/436/1*P1j64IZl61xBbJsaxjXbPA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*td5OoSWZPlQfqM3A95wcfA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/653/1*HN3m9wOQIyaXdxuyOMtQRw.png" /></figure><p><strong>Let’s take a closer look at these three matrices starting with U:</strong></p><p>So the first column of U represents weights that would match each user’s preference to movies categorized under Sci-Fi while the second column of U represents weights that would match each user’s preference to movies under the romance category. For example, the first user greatly prefers sci-fi movies(0.13 score) compared to romance(0.02 score). As for the third column, we won’t consider it for now.</p><p><strong>And for 𝚺,</strong></p><p>The first diagonal entry represents the weight of the Sci-Fi category and the second diagonal entry represents the weight of the romance category.</p><p><strong>And for V,</strong></p><p>The columns depict the degree to which a movie belongs to a category. So, for example, we can see from the first column of <strong>V </strong>that the first movie(this would be Avengers) belongs heavily to the Sci-Fi(0.56 score) category and very little to the romance category(0.12 score).</p><blockquote><strong>Note: </strong>we have not considered the third dimension of each matrix at all. Well, this is because when you look at matrix 𝚺, the third diagonal entry which represents the weight of a movie category has a small value(1.3 score). This is understandable because we only have two categories of movies. So most of the third dimension is considered as noise.</blockquote><p>So its the above note that we use to perform dimensionality reduction to the matrices <strong>A</strong>. We do this by eliminating the third dimension of 𝚺, this would also mean eliminating the third column of <strong>U</strong> and the third row of <strong>V</strong> to produce the following new <strong>U, 𝚺 </strong>and,<strong> V</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/314/1*MyqVAQSVrf3F-Y3fA3dYBQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/261/1*lf59ziSZa0dWRCZzLyhj7Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/658/1*caHUK2V4qlqRq78PaHr3Aw.png" /></figure><p>So as you can see, the final matrices U𝚺V are smaller than the initial ones since we have eliminated the third dimension.</p><p>To confirm that eliminating the given rows and columns as we have done only affects the initial matrix A to a small extent. Let’s multiply the above three matrices to get matrix B below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/650/1*qllC2BfRo0JtFpfdNwUKvQ.png" /></figure><p>So Let’s compare this matrix B with the original matrix <strong>A</strong> below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/269/1*6IK5KxxAYOI9OXYd0yuSHg.png" /></figure><p>Just by looking at the above two matrices, you can tell that the difference between their elements is very small, in other words, the product of our final three matrices <strong>B</strong>(after SVD)<strong> </strong>≈ <strong>A</strong>(before SVD):</p><p>Or mathematically this can be represented as the <a href="https://en.wikipedia.org/wiki/Matrix_norm#Frobenius_norm">Frobenius norm</a>. Which is the square root of the summation of the squares of the differences between the individual matrix entries. It can be represented by the equation below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/450/1*BzYuCpUCxQamDEwn6vh2yg.png" /></figure><p>So this is how we are able to decompose a matrix into lower rank matrices without losing much of the important data.</p><p>It also helps to analyse and acquire important information concerning the matrix data.</p><p>There are many other applications of SVD other than the ones talked about in this article. Some of the others include data compression, solving the pseudo-inverse and search engines like Google use SVD to compute approximations of enormous matrices that provide compression ratios of millions to one. So searching for a term is much quicker.</p><p>So hopefully this reading can give you a clear picture of this fundamental linear algebra concept and its application in Machine Learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=162ac796c27d" width="1" height="1" alt=""><hr><p><a href="https://medium.com/the-andela-way/foundations-of-machine-learning-singular-value-decomposition-svd-162ac796c27d">Foundations of Machine Learning : Singular Value Decomposition (SVD)</a> was originally published in <a href="https://medium.com/the-andela-way">The Andela Way</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>