<?xml version="1.0" encoding="utf-8"?> 
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
 <title type="text">SHRIPHANI PALAKODETY: Posts tagged 'kernel-pca'</title>
 <link rel="self" href="http://blog.shriphani.com/feeds/kernel-pca.atom.xml" />
 <link href="http://blog.shriphani.com/tags/kernel-pca.html" />
 <id>urn:http-blog-shriphani-com:-tags-kernel-pca-html</id>
 <updated>2015-01-22T03:31:29Z</updated>
 <entry>
  <title type="text">Dimension Analysis: A Recap</title>
  <link rel="alternate" href="http://blog.shriphani.com/2015/01/21/dimension-analysis-a-recap/?utm_source=kernel-pca&amp;utm_medium=Atom" />
  <id>urn:http-blog-shriphani-com:-2015-01-21-dimension-analysis-a-recap</id>
  <published>2015-01-22T03:31:29Z</published>
  <updated>2015-01-22T03:31:29Z</updated>
  <author>
   <name>SHRIPHANI PALAKODETY</name></author>
  <content type="html">&lt;html&gt;
&lt;p&gt;In the past few blog posts, I covered some details of popular dimension-reduction techniques and showed some common themes. In this post, I will collect all these materials and tie them together.&lt;/p&gt;
&lt;!-- more--&gt;

&lt;h3 id="dimension"&gt;Dimension?&lt;/h3&gt;

&lt;p&gt;The best definition I&amp;rsquo;ve seen for the topic comes from Benoit Mandelbrot&amp;rsquo;s work on &lt;a href="http://en.wikipedia.org/wiki/Fractal_Dimension"&gt;fractal geometry&lt;/a&gt;. The fractal dimension is associated with the ability of a pattern to fill space. Here&amp;rsquo;s a good example to illustrate what we mean.&lt;/p&gt;

&lt;p&gt;Consider a curve viewed at three different scales (image stolen from Chris Burges&amp;rsquo;s document on dimension reduction):&lt;/p&gt;

&lt;p&gt;&lt;img src="/img/rectangle_example.png" /&gt;&lt;/p&gt;

&lt;p&gt;Now, at a microscopic level, we begin observing. How do we observe? Assume that a there&amp;rsquo;s a sphere around the observer. Now, let this sphere expand a bit. At the microscopic level, your sphere encounters more of the curve&amp;rsquo;s material in 2 dimensions. This is illustrated in the rightmost figure.&lt;/p&gt;

&lt;p&gt;Now, at a slightly different scale, when our sphere expands, we observe more material along just 1 dimension. This is illustrated in the middle figure.&lt;/p&gt;

&lt;p&gt;On a scale like the one in the leftmost pic, we encounter no material at all. This is akin to a zero-dimension figure (a point).&lt;/p&gt;

&lt;p&gt;An intuitive explanation of why scale matters is provided in this Wikipedia example. Using a ruler of different lengths, we obtain different measures for the coastline of Great Britain. At various levels of scale, we acquire various measures of the coastline - using a ruler that is as long as the diameter of the earth, the coastline of britain is a negligible fraction of our instrument.&lt;/p&gt;

&lt;p&gt;&lt;img src="http://upload.wikimedia.org/wikipedia/commons/7/78/Britain-fractal-coastline-200km.png" /&gt; &lt;img src="http://upload.wikimedia.org/wikipedia/commons/c/c8/Britain-fractal-coastline-100km.png" /&gt; &lt;img src="http://upload.wikimedia.org/wikipedia/commons/f/f9/Britain-fractal-coastline-50km.png" /&gt;&lt;/p&gt;

&lt;p&gt;There&amp;rsquo;s a neat formula that can be used to estimate the fractal dimension of a dataset:&lt;/p&gt;

&lt;ul&gt;
 &lt;li&gt;$ n $: The number of pairs of points in our data.&lt;/li&gt;
 &lt;li&gt;$ r $: The radius of a sphere centered around the observer.&lt;/li&gt;
 &lt;li&gt;$ p $: The number of pairs of points in a sphere of radius $ r $.&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;The estimate of the fractal dimension is given by the slope of $ \log(p) $ vs $ \log(r) $.&lt;/p&gt;

&lt;p&gt;For the curve in the example above, this value is some real number between 1 and 2 (so the points on the curve have more freedom than those on a line but less freedom than those on a 2D-plane).&lt;/p&gt;

&lt;h3 id="a-first-stab-at-dimension-reduction"&gt;A First Stab at Dimension Reduction&lt;/h3&gt;

&lt;p&gt;Working with intuitions we developed in the first section, we can develop a greedy algorithm:&lt;/p&gt;

&lt;ul&gt;
 &lt;li&gt;Estimate the fractal-dimension of the dataset.&lt;/li&gt;
 &lt;li&gt;Choose a dimension (column) to drop, drop it and recompute the  fractal-dimension. If the dimension doesn&amp;rsquo;t change too much (stays  within a certain tolerance), consider this dimension dropped.&lt;/li&gt;
 &lt;li&gt;Repeat until no more dimensions can be dropped without significantly  altering the fractal-dimension.&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;This is the Grassberger-Procaccia algorithm.&lt;/p&gt;

&lt;p&gt;It is intuitive to grasp.&lt;/p&gt;

&lt;p&gt;However, &lt;strong&gt;in a high-dimension setting, our technique for estimating fractal dimensions falls apart&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In a high-dimensional setting, pairwise distances between the points in a dataset are tightly clustered about a mean. Essentially, the points seem to be equidistant from each other. A Hoeffding bound is provided in &lt;a href="/2013/11/29/a-comment-on-dimension-estimation/"&gt;this blog post&lt;/a&gt; that illustrates this point.&lt;/p&gt;

&lt;h3 id="the-pca"&gt;The PCA&lt;/h3&gt;

&lt;p&gt;One common attempt at reducing dimensions is capturing directions of maximum variance. The PCA projects points in the dataset along the eigenvectors of the covariance matrix. Since this technique is well-known, I&amp;rsquo;ll just point to this &lt;a href="http://en.wikipedia.org/wiki/Principal_component_analysis"&gt;Wikipedia article&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id="from-proximities-to-datasets"&gt;From Proximities to Datasets&lt;/h3&gt;

&lt;p&gt;A family of techniques I like a lot operate on proximity matrices. A proximity matrix is a symmetric matrix containing similarity scores between the points in a dataset (thus this matrix contains $ n $ rows and $ n $ columns where $ n $ is the number of points in the dataset).&lt;/p&gt;

&lt;p&gt;A simple argument demonstrates that proximity matrices are gram matrices (a gram matrix is a close cousin of the covariance matrix). One can retrieve a collection of points for a given gram matrix - see &lt;a href="/2015/01/15/multidimensional-scaling-and-pca-are-the-same-thing/"&gt;this blog post&lt;/a&gt; for a proof.&lt;/p&gt;

&lt;p&gt;This family of techniques formulates the dimension-reduction problem as such: &amp;ldquo;Find a configuration of points in a lower-dimensional place that preserves the proximities in the proximity matrix&amp;rdquo;.&lt;/p&gt;

&lt;p&gt;The standard MDS algorithm uses euclidean distances between points to populate the proximity matrix. &lt;a href="/2014/10/29/low-dimension-embeddings-for-visualization/"&gt;This blog post&lt;/a&gt; contains more info about this algorithm.&lt;/p&gt;

&lt;p&gt;A variant of this algorithm uses path-weights in a $k$-NN graph. This is the Isomap algorithm - covered &lt;a href="/2014/11/12/the-isomap-algorithm/"&gt;in this post&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id="the-kernel-trick"&gt;The Kernel Trick&lt;/h3&gt;

&lt;p&gt;The Kernel trick is leveraged in settings where we transform our points to a higher-dimensional space to make the desired insight pop out. This desired insight is a hyperplane to separate two different classes when working with a classifier. In Kernel PCA, the desired insight is capturing variances so you can run a PCA on the newer dataset in a higher-dimension.&lt;/p&gt;

&lt;p&gt;Interestingly, MDS and Isomap are all variants of the Kernel PCA - a topic explored in &lt;a href="/2015/01/20/the-kernel-pca/"&gt;this blog post&lt;/a&gt;.&lt;/p&gt;

&lt;h3 id="up-next"&gt;Up Next&lt;/h3&gt;

&lt;p&gt;In future blog posts, I will discuss scaling issues with spectral algorithms, insights that can be transferred to other domains and so on.&lt;/p&gt;&lt;/html&gt;</content></entry>
 <entry>
  <title type="text">The Kernel PCA</title>
  <link rel="alternate" href="http://blog.shriphani.com/2015/01/20/the-kernel-pca/?utm_source=kernel-pca&amp;utm_medium=Atom" />
  <id>urn:http-blog-shriphani-com:-2015-01-20-the-kernel-pca</id>
  <published>2015-01-21T02:28:09Z</published>
  <updated>2015-01-21T02:28:09Z</updated>
  <author>
   <name>SHRIPHANI PALAKODETY</name></author>
  <content type="html">&lt;html&gt;
&lt;p&gt;The Kernel PCA is an extension of the PCA algorithm. In particular, we desire to (i) transform our existing dataset to another high-dimensional space and then (ii) perform PCA on the data in that space.&lt;/p&gt;

&lt;p&gt;In this blog post, I will perform a very quick, non-rigorous overview of Kernel PCA and demonstrate some connections between other forms of dimension-reduction.&lt;/p&gt;

&lt;p&gt;Why would this be useful? Consider this dataset (stolen from the scikit-learn documentation):&lt;/p&gt;

&lt;p&gt;&lt;img src="http://scikit-learn.org/stable/_images/plot_kernel_pca_001.png" /&gt;&lt;/p&gt;

&lt;p&gt;As we can see, the original PCA projection is fairly useless. Applying a kernel produces a much better projection.&lt;/p&gt;

&lt;p&gt;Like kernels in several problems, the trick is to avoid transforming data-points and leveraging dot-products.&lt;/p&gt;

&lt;p&gt;The technique is as follows:&lt;/p&gt;

&lt;p&gt;$ \Phi $ is a mapping from our existing point-space to a higher-dimensional space $ \mathcal{F} $.&lt;/p&gt;

&lt;p&gt;After a certain amount of linear algebra, the PCA in space $ \mathcal{F} $ can be expressed as a PCA on the &lt;a href="http://en.wikipedia.org/wiki/Kernel_method"&gt;kernel matrix&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;So, the algorithm is expressible as follows:&lt;/p&gt;

&lt;ul&gt;
 &lt;li&gt;
  &lt;p&gt;Compute the kernel matrix $ K $ where $ K_{ij} = \Phi(x_i) \cdot \Phi(x_j) $.&lt;/p&gt;&lt;/li&gt;
 &lt;li&gt;
  &lt;p&gt;This matrix is efficiently constructed since we can obtain the  constituent dot products in the original space.&lt;/p&gt;&lt;/li&gt;
 &lt;li&gt;
  &lt;p&gt;The SVD of $ K $ gives you $ USV^{T} $ - $ U $ and $ S $ can be used  to construct a reduced dimension dataset.&lt;/p&gt;&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt;Now that the intro is out of the way, I wanted to demonstrate some simple connections between algorithms I&amp;rsquo;ve covered recently:&lt;/p&gt;

&lt;h3 id="mds-with-euclidean-distances"&gt;MDS with Euclidean Distances&lt;/h3&gt;

&lt;p&gt;In &lt;a href="http://blog.shriphani.com/2015/01/15/multidimensional-scaling-and-pca-are-the-same-thing/"&gt;previous blog posts&lt;/a&gt;, we covered that MDS and PCA are equivalent. A simple proof exists to show that MDS and Kernel PCA are the same thing:&lt;/p&gt;

&lt;ul&gt;
 &lt;li&gt;The proximity matrix in the MDS algorithm is built with  distances. We can express distances between vectors $ x $ and $ y $ as:&lt;/li&gt;&lt;/ul&gt;

&lt;p&gt; 
 &lt;div&gt;$$ d(x,y) = x \cdot x + y \cdot y &amp;ndash; 2x \cdot y $$&lt;/div&gt;&lt;/p&gt;

&lt;ul&gt;
 &lt;li&gt;Thus, distances can be expressed as a kernel. The upshot of this is  that the MDS algorithm itself is an instance of Kernel PCA.&lt;/li&gt;&lt;/ul&gt;

&lt;h3 id="isomap"&gt;Isomap&lt;/h3&gt;

&lt;p&gt;The Isomap algorithm (covered in a &lt;a href="http://blog.shriphani.com/2014/11/12/the-isomap-algorithm/"&gt;previous post&lt;/a&gt;) trades the Euclidean distance with edge weights in a nearest neighbor graph. The entries in this proximity matrix are surrogates for distances and thus the Isomap algorithm is an instance of Kernel PCA as well.&lt;/p&gt;

&lt;p&gt;It is amazing how several different approaches to dimension-reduction are variants of a single theme.&lt;/p&gt;&lt;/html&gt;</content></entry></feed>