<p><div><div><div><div data-width="100" data-show-faces="false" data-send="true" data-layout="button_count" data-height="21" data-href="http://www.r-bloggers.com/the-kernel-trick-in-support-vector-machines-seeing-similarity-in-more-intricate-dimensions/"></div></div><div><a data-url="http://www.r-bloggers.com/the-kernel-trick-in-support-vector-machines-seeing-similarity-in-more-intricate-dimensions/" data-counturl="http://www.r-bloggers.com/the-kernel-trick-in-support-vector-machines-seeing-similarity-in-more-intricate-dimensions/" data-count="horizontal" data-text="The Kernel Trick in Support Vector Machines: Seeing Similarity in More Intricate Dimensions" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
(This article was first published on <strong><a href="http://joelcadwell.blogspot.com/2016/05/the-kernel-trick-in-support-vector.html"> Engaging Market Research</a></strong>, and kindly contributed to <a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers)</a> </div>
<p>The “kernel” is the seed or the essence at the heart or the core, and the kernel function measures distance from that center. In the following <a target="_blank" href="https://en.wikipedia.org/wiki/Kernel_(statistics)">example from Wikipedia</a>, the kernel is at the origin and the different curves illustrate alternative depictions of what happens as we move away from zero.</p>
<div><a target="_blank" href="https://3.bp.blogspot.com/-ovokmnyruro/Vz-IC_hjdzI/AAAAAAAAAZk/nt-HTNQrtA4hk6MGbfjGT1sQVefk2AKnwCLcB/s1600/590px-Kernels.svg.png"><img height="287" width="400" src="https://3.bp.blogspot.com/-ovokmnyruro/Vz-IC_hjdzI/AAAAAAAAAZk/nt-HTNQrtA4hk6MGbfjGT1sQVefk2AKnwCLcB/s400/590px-Kernels.svg.png" border="0"></a></div>
<p>At what temperature do you prefer your first cup of coffee? If we center the scale at that temperature, how do we measure the effects of deviations from the ideal level. The uniform kernel function tells us that closest to the optimal makes little difference as long as it is within a certain range. You might feel differently, perhaps it is a constant rate of disappointment as you move away from the best temperature in either direction (a triangular kernel function). However, for most us, satisfaction takes the form of exponential decay with a Gaussian kernel describing our preferences as we deviate from the very best.</p>
<p><a target="_blank" href="https://cran.r-project.org/web/packages/HSAUR/vignettes/Ch_density_estimation.pdf">Everitt and Hothorn</a> show how it is done in R for density estimation. Of course, the technique works with any variable, not just preference or distance from the ideal. Moreover, the logic is the same: give greater weight to closer data. And how does one measure closeness? You have many alternatives, as shown above, varying from tolerant to strict. What counts as the same depends on your definition of sameness. With human vision the person retains their identity and our attention as they walk from the shade into the sunlight; my old camera has a different kernel function and fails to keep track or focus correctly. In addition, when the density being estimated is multivariate, you have the option of differential weighting of each variable so that some aspects will count a great deal and others can be ignored.</p>
<div></div>
<p>Now, with the preliminaries over, we can generalize the kernel concept to support vector machines (SVMs). First, we will expand our feature space because the optimal cup of coffee depends on more than its temperature (e.g., preparation method, coffee bean storage, variation on finest and method of grind, ratio of coffee to water, and don’t forget the the type of bean and its processing). You tell me the profile of two coffees using all those features that we just enumerated, and I will calculate their pairwise similarity. If their profiles are identical, the two coffees are the same and centered at zero. But if they are not identical, how important are the differences? Finally, we ought to remember that differences are measured with respect to satisfaction, that is, two equally pleasing coffees may have different profiles but the differences are not relevant.</p>
<p><a target="_blank" href="http://joelcadwell.blogspot.com/2016/05/the-mad-hatter-explains-support-vector.html">As the Mad Hatter explained in the last post</a>, SVMs live in the observation space, in this case, among all the different cups of coffees. We will need a data matrix with a bunch of coffees for taste testing in the rows and all those features as columns, plus an additional column with a satisfaction rating or at least a thumbs-up or thumbs-down. Keeping it simple, we will stay with a classification problem distinguishing good from bad coffees. Can I predict your coffee preference from those features? Unfortunately, individual tastes are complex and that strong coffee may be great for some but only when hot. What of those who don’t like strong coffee? It is, as if, we had multiple configurations of interacting nonlinear features with many more dimensions than can be represented in the original feature space.</p>
<p>Our training data from the taste tests might contain actual coffees near each of these configurations differentiating the good and the bad. These are the support vectors of SVMs, what Andrew Ng calls “landmarks” in <a target="_blank" href="https://www.youtube.com/watch?v=2NHSmv8n1-U">his Coursera course</a> and <a target="_blank" href="http://www.holehouse.org/mlclass/12_Support_Vector_Machines.html">his more advanced class at Stanford</a>. In this case, the support vectors are actual cups of coffee that you can taste and judge as good or bad. Chapter 9 of <a target="_blank" href="http://www.r-bloggers.com/in-depth-introduction-to-machine-learning-in-15-hours-of-expert-videos/">An Introduction to Statistical Learning</a> will walk you through the steps, including how to run the R code, but you might leave without a good intuitive grasp of the process.</p>
<p>It would help to remember that a logistic regression equation and the coefficients from a discriminant analysis yield a single classification dimension when you have two groupings. What happens when there are multiple ways to succeed or fail? I can name several ways to prepare different types of coffee, and I am fond of them all. Similarly, I can recall many ways to ruin a cup of coffee. Think of each as a support vector from the training set and the classification function as a weighted similarity to instances from this set. If a new test coffee is similar to one called “good” from the training data, we might want to predict “good” for this one too. The same applies to coffees associated with the “bad” label.</p>
<p>The key is the understanding that the features from our data matrix are no longer the dimensions underlying this classification space. We have redefined the basis in terms of landmarks or support vectors. New coffees are placed along dimensions defined by previous training instances. <a target="_blank" href="https://www.youtube.com/watch?v=B8J4uefCQMc">As Pedro Domingos notes</a> (at 33 minutes into the talk), the algorithm relies on analogy, not unlike case-based reasoning. Our new dimensions are more intricate compressed representations of the original features. If this reminds you of <a target="_blank" href="http://joelcadwell.blogspot.com/2012/07/archetypal-analysis.html">archetypal analysis</a>, then you may be on the right track or at least not entirely lost.</p>
<p><div><div><div><div data-width="55" data-show-faces="false" data-send="true" data-layout="box_count" data-height="62" data-href="http://www.r-bloggers.com/the-kernel-trick-in-support-vector-machines-seeing-similarity-in-more-intricate-dimensions/"></div></div><div><a data-url="http://www.r-bloggers.com/the-kernel-trick-in-support-vector-machines-seeing-similarity-in-more-intricate-dimensions/" data-counturl="http://www.r-bloggers.com/the-kernel-trick-in-support-vector-machines-seeing-similarity-in-more-intricate-dimensions/" data-count="vertical" data-text="The Kernel Trick in Support Vector Machines: Seeing Similarity in More Intricate Dimensions" class="twitter-share-button" data-via="rbloggers" href="https://twitter.com/share"></a></div><div></div></div><div></div></div>
<div>
<div>To <strong>leave a comment</strong> for the author, please follow the link and comment on their blog: <strong><a href="http://joelcadwell.blogspot.com/2016/05/the-kernel-trick-in-support-vector.html"> Engaging Market Research</a></strong>.</div>
<hr>
<a rel="nofollow" href="http://www.r-bloggers.com/">R-bloggers.com</a> offers <strong><a rel="nofollow" href="http://feedburner.google.com/fb/a/mailverify?uri=RBloggers">daily e-mail updates</a></strong> about <a title="The R Project for Statistical Computing" rel="nofollow" href="http://www.r-project.org/">R</a> news and <a title="R tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=tutorial">tutorials</a> on topics such as: <a title="Data science" rel="nofollow" href="http://www.r-bloggers.com/?s=data%20science">Data science</a>, <a title="Big Data" rel="nofollow" href="http://www.r-bloggers.com/?s=Big%20Data">Big Data, <a title="R jobs" rel="nofollow" href="http://www.r-users.com/">R jobs</a>, visualization (<a title="ggplot and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=ggplot2">ggplot2</a>, <a title="Boxplots using lattice and ggplot2 tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=boxplot">Boxplots</a>, <a title="Maps and gis" rel="nofollow" href="http://www.r-bloggers.com/?s=map">maps</a>, <a title="Animation in R" rel="nofollow" href="http://www.r-bloggers.com/?s=animation">animation</a>), programming (<a title="RStudio IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=RStudio">RStudio</a>, <a title="Sweave and literate programming" rel="nofollow" href="http://www.r-bloggers.com/?s=sweave">Sweave</a>, <a title="LaTeX in R" rel="nofollow" href="http://www.r-bloggers.com/?s=LaTeX">LaTeX</a>, <a title="SQL and databases" rel="nofollow" href="http://www.r-bloggers.com/?s=SQL">SQL</a>, <a title="Eclipse IDE for R" rel="nofollow" href="http://www.r-bloggers.com/?s=eclipse">Eclipse</a>, <a title="git and github, Version Control System" rel="nofollow" href="http://www.r-bloggers.com/?s=git">git</a>, <a title="Large data in R using Hadoop" rel="nofollow" href="http://www.r-bloggers.com/?s=hadoop">hadoop</a>, <a title="Web Scraping of google, facebook, yahoo, twitter and more using R" rel="nofollow" href="http://www.r-bloggers.com/?s=Web+Scraping">Web Scraping</a>) statistics (<a title="Regressions and ANOVA analysis tutorials" rel="nofollow" href="http://www.r-bloggers.com/?s=regression">regression</a>, <a title="principal component analysis tutorial" rel="nofollow" href="http://www.r-bloggers.com/?s=PCA">PCA</a>, <a title="Time series" rel="nofollow" href="http://www.r-bloggers.com/?s=time+series">time series</a>, <a title="finance trading" rel="nofollow" href="http://www.r-bloggers.com/?s=trading">trading</a>) and more...
<img height="1" alt="" width="1" src="http://feeds.feedburner.com/~r/RBloggers/~4/q64eFVSCnHc"></a></div>