{"id":77467,"date":"2020-03-13T09:43:03","date_gmt":"2020-03-13T04:13:03","guid":{"rendered":"https:\/\/techvidvan.com\/tutorials\/?p=77467"},"modified":"2020-03-13T09:43:03","modified_gmt":"2020-03-13T04:13:03","slug":"svm-kernel-functions","status":"publish","type":"post","link":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/","title":{"rendered":"SVM Kernel Functions &#8211; &#8216;Coz your SVM knowledge is incomplete without it"},"content":{"rendered":"<p>The kernel functions play a very important role in SVM. Their job is to take data as input and they transform it in any required form. They are significant in SVM as they help in determining various important things.<\/p>\n<p>In this article, we will be looking at various types of kernels. We will also be looking at how the kernel works and why is it necessary to have a kernel function. This will be an important article, as it will give an idea of what kernel function should be used in specific programs.<\/p>\n<h3>What is Kernel?<\/h3>\n<p>A kernel is a function used in SVM for helping to solve problems. They provide shortcuts to avoid complex calculations. The amazing thing about kernel is that we can go to higher dimensions and perform smooth calculations with the help of it.<\/p>\n<p>We can go up to an <strong>infinite<\/strong> number of dimensions using kernels.<\/p>\n<p>Sometimes, we cannot have a hyperplane for certain problems. This problem arises when we go up to higher dimensions and try to form a hyperplane.<\/p>\n<p>A kernel helps to form the hyperplane in the higher dimension without raising the complexity.<\/p>\n<h3>Working of Kernel Functions<\/h3>\n<p>Kernels are a way to solve non-linear problems with the help of linear classifiers. This is known as the <strong>kernel trick<\/strong> method. The kernel functions are used as parameters in the SVM codes. They help to determine the shape of the hyperplane and decision boundary.<\/p>\n<p>We can set the value of the kernel parameter in the SVM code.<\/p>\n<p>The value can be any type of kernel from linear to polynomial. If the value of the kernel is linear then the decision boundary would be linear and two-dimensional. These kernel functions also help in giving decision boundaries for higher dimensions.<\/p>\n<p>We do not need to do complex calculations. The kernel functions do all the hard work. We just have to give the input and use the appropriate kernel. Also, we can solve the overfitting problem in SVM using the kernel functions.<\/p>\n<p><strong>Overfitting<\/strong> happens when there are more feature sets than sample sets in the data. We can solve the problem by either increasing the data or by choosing the right kernel.<\/p>\n<p>There are kernels like <strong>RBF<\/strong> that work well with smaller data as well. But, RBF is a universal kernel and using it on smaller datasets might increase the chances of overfitting.<\/p>\n<p>Hence, the use of simpler kernels like linear and polynomial is encouraged.<\/p>\n<h3>Rules of Kernel Functions<\/h3>\n<p>There are certain rules which the kernel functions must follow.<\/p>\n<p>Also, these rules are the deciding factors of what kernel should be implemented for classification. One such rule is the<strong> moving window classifier<\/strong> or we can also call it the <strong>window function<\/strong>.<\/p>\n<p>This function is shown as:<\/p>\n<p><strong>f<sub>n<\/sub>(x) = 1, if \u2211 ?(|| x &#8211; x<sub>i<\/sub>|| &lt;= h)? (y<sub>i<\/sub>=1) &gt; \u2211 ?(|| x &#8211; x<sub>i<\/sub>|| &lt;= h)? (y<sub>i<\/sub>=0)<\/strong><br \/>\n<strong>f<sub>n<\/sub>(x) = 0<\/strong>, otherwise.<\/p>\n<p>Here, the summations are from i=1 to n. \u2018h\u2019 is the width of the window. This rule assigns weights to the points at a fixed distance from \u2018x\u2019.<\/p>\n<p>\u2018x<sub>i<\/sub>\u2019 are the points nearby \u2018x\u2019.<\/p>\n<p>It is essential that the weights should be distributed in the direction of x<sub>i<\/sub>. This ensures the smooth working of the weight functions. These weight functions are the kernel functions.<\/p>\n<p>The kernel function is represented as <strong>K: R<sup>d<\/sup>-&gt; R<\/strong>.<\/p>\n<p>The functions are generally positive and monotonically decreasing. There are some forms of these functions:<\/p>\n<ul>\n<li>Uniform kernels: <strong>K(x) = ?(||x||&lt;=1)<\/strong><\/li>\n<\/ul>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/03\/uniform-kernel-function.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-77476 size-full\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/03\/uniform-kernel-function.jpg\" alt=\"uniform kernel function\" width=\"578\" height=\"241\" \/><\/a><\/p>\n<ul>\n<li>Gaussian kernels: <strong>K(x) = exp(-||x||<sup>2<\/sup>)<\/strong><\/li>\n<\/ul>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/03\/gaussian-kernel-function.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-77477 size-full\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/03\/gaussian-kernel-function.jpg\" alt=\"gaussian kernel functions\" width=\"490\" height=\"353\" \/><\/a><\/p>\n<ul>\n<li>Epanechnikov kernels: <strong>?(1-||x||<sup>2<\/sup>)?(||x||&lt;=1)<\/strong><\/li>\n<\/ul>\n<p><a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/03\/epanechnikov-kernel-function.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-77478 size-full\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/03\/epanechnikov-kernel-function.jpg\" alt=\"epanechnikov kernel functions\" width=\"558\" height=\"271\" \/><\/a><\/p>\n<h3>Types of Kernel Functions<a href=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/03\/types-of-kernel-functions.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter wp-image-77480 size-full\" src=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/sites\/2\/2020\/03\/types-of-kernel-functions.jpg\" alt=\"types of kernel functions\" width=\"550\" height=\"568\" \/><\/a><\/h3>\n<h4>1. Polynomial Kernel Function<\/h4>\n<p>The polynomial kernel is a general representation of kernels with a degree of more than one. It\u2019s useful for image processing.<\/p>\n<p>There are two types of this:<\/p>\n<ul>\n<li><strong>Homogenous Polynomial Kernel Function<\/strong><\/li>\n<\/ul>\n<p><strong>K(x<sub>i<\/sub>,x<sub>j<\/sub>) = (x<sub>i<\/sub>.x<sub>j<\/sub>)<sup>d<\/sup><\/strong>, where \u2018.\u2019 is the dot product of both the numbers and d is the degree of the polynomial.<\/p>\n<ul>\n<li><strong>Inhomogeneous Polynomial Kernel Function<\/strong><\/li>\n<\/ul>\n<p><strong>K(x<sub>i<\/sub>,x<sub>j<\/sub>) = (x<sub>i<\/sub>.x<sub>j<\/sub> + c)<sup>d<\/sup><\/strong> where c is a constant.<\/p>\n<h4>2. Gaussian RBF Kernel Function<\/h4>\n<p>RBF is the radial basis function. This is used when there is no prior knowledge about the data.<\/p>\n<p>It\u2019s represented as:<\/p>\n<p><strong>K(x<sub>i<\/sub>,x<sub>j<\/sub>) = exp(-\u03b3||x<sub>i<\/sub> \u2013 x<sub>j<\/sub>||)<sup>2<\/sup><\/strong><\/p>\n<h4>3. Sigmoid Kernel Function<\/h4>\n<p>This is mainly used in neural networks. We can show this as:<\/p>\n<p><strong>K(x<sub>i<\/sub>,x<sub>j<\/sub>) = tanh(\u03b1x<sup>a<\/sup>y + c)<\/strong><\/p>\n<h4>4. Hyperbolic Tangent Kernel Function<\/h4>\n<p>This is also used in neural networks. The equation is:<\/p>\n<p><strong>K(x<sub>i<\/sub>,x<sub>j<\/sub>) = tanh(kx<sub>i<\/sub>.x<sub>j<\/sub> + c)<\/strong><\/p>\n<h4>5. Linear Kernel Function<\/h4>\n<p>This kernel is one-dimensional and is the most basic form of kernel in SVM. The equation is:<\/p>\n<p><strong>K(x<sub>i<\/sub>,x<sub>j<\/sub>) = x<sub>i<\/sub>.x<sub>j<\/sub> + c<\/strong><\/p>\n<h4>6. Graph Kernel Function<\/h4>\n<p>This kernel is used to compute the inner on graphs. They measure the similarity between pairs of graphs. They contribute in areas like <strong>bioinformatics<\/strong>, <strong>chemoinformatics<\/strong>, etc.<\/p>\n<h4>7. String Kernel Function<\/h4>\n<p>This kernel operates on the basis of strings. It is mainly used in areas like <strong>text<\/strong> <strong>classification<\/strong>. They are very useful in text mining, genome analysis, etc.<\/p>\n<h4>8. Tree Kernel Function<\/h4>\n<p>This kernel is more associated with the tree structure. The kernel helps to split the data into tree format and helps the SVM to distinguish between them. This is helpful in language classification and it is used in areas like <strong>NLP<\/strong>.<\/p>\n<h3>Summary<\/h3>\n<p>This was all about the SVM Kernel Functions article. There are various more types of kernels but we have covered the ones that are useful for beginners.<\/p>\n<p>From this article, we understood that kernel is a highly mathematical concept of Machine Learning. We saw how it works and how and where are the various types of kernels used. Then, we also saw what type of problems does the kernel tackles. There were also some kernel rules which are important to understand.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The kernel functions play a very important role in SVM. Their job is to take data as input and they transform it in any required form. They are significant in SVM as they help&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":77481,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[210],"tags":[2037,2038,2039,2040,2041,2042,2043],"class_list":["post-77467","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-machine-learning","tag-kernel-functions","tag-rules-of-kernel-functions","tag-svm-kernel-functions","tag-types-of-kernel-functions","tag-what-is-a-kernel-in-machine-learning","tag-what-is-kernel","tag-working-of-kernel-functions"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.7 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>SVM Kernel Functions - &#039;Coz your SVM knowledge is incomplete without it - TechVidvan<\/title>\n<meta name=\"description\" content=\"Explore what is Kernel, how kernel functions play a very important role in SVM, what are its various types and how does Kernel Function works and tackles the problem.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"SVM Kernel Functions - &#039;Coz your SVM knowledge is incomplete without it - TechVidvan\" \/>\n<meta property=\"og:description\" content=\"Explore what is Kernel, how kernel functions play a very important role in SVM, what are its various types and how does Kernel Function works and tackles the problem.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/\" \/>\n<meta property=\"og:site_name\" content=\"TechVidvan\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/TechVidvan\/\" \/>\n<meta property=\"article:published_time\" content=\"2020-03-13T04:13:03+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/03\/SVM-kernel-function.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"802\" \/>\n\t<meta property=\"og:image:height\" content=\"420\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"TechVidvan Team\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:site\" content=\"@vidvantech\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"TechVidvan Team\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"6 minutes\" \/>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"SVM Kernel Functions - 'Coz your SVM knowledge is incomplete without it - TechVidvan","description":"Explore what is Kernel, how kernel functions play a very important role in SVM, what are its various types and how does Kernel Function works and tackles the problem.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/","og_locale":"en_US","og_type":"article","og_title":"SVM Kernel Functions - 'Coz your SVM knowledge is incomplete without it - TechVidvan","og_description":"Explore what is Kernel, how kernel functions play a very important role in SVM, what are its various types and how does Kernel Function works and tackles the problem.","og_url":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/","og_site_name":"TechVidvan","article_publisher":"https:\/\/www.facebook.com\/TechVidvan\/","article_published_time":"2020-03-13T04:13:03+00:00","og_image":[{"width":802,"height":420,"url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/03\/SVM-kernel-function.jpg","type":"image\/jpeg"}],"author":"TechVidvan Team","twitter_card":"summary_large_image","twitter_creator":"@vidvantech","twitter_site":"@vidvantech","twitter_misc":{"Written by":"TechVidvan Team","Est. reading time":"6 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/#article","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/"},"author":{"name":"TechVidvan Team","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22"},"headline":"SVM Kernel Functions &#8211; &#8216;Coz your SVM knowledge is incomplete without it","datePublished":"2020-03-13T04:13:03+00:00","mainEntityOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/"},"wordCount":961,"commentCount":0,"publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/03\/SVM-kernel-function.jpg","keywords":["Kernel Functions","Rules of Kernel Functions","SVM Kernel Functions","Types of Kernel Functions","what is a kernel in machine learning","What is Kernel?","Working of Kernel Functions"],"articleSection":["Machine Learning Tutorials"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/","url":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/","name":"SVM Kernel Functions - 'Coz your SVM knowledge is incomplete without it - TechVidvan","isPartOf":{"@id":"https:\/\/techvidvan.com\/tutorials\/#website"},"primaryImageOfPage":{"@id":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/#primaryimage"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/#primaryimage"},"thumbnailUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/03\/SVM-kernel-function.jpg","datePublished":"2020-03-13T04:13:03+00:00","description":"Explore what is Kernel, how kernel functions play a very important role in SVM, what are its various types and how does Kernel Function works and tackles the problem.","breadcrumb":{"@id":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/#primaryimage","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/03\/SVM-kernel-function.jpg","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2020\/03\/SVM-kernel-function.jpg","width":802,"height":420,"caption":"kernel functions in svm"},{"@type":"BreadcrumbList","@id":"https:\/\/techvidvan.com\/tutorials\/svm-kernel-functions\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/techvidvan.com\/tutorials\/"},{"@type":"ListItem","position":2,"name":"SVM Kernel Functions &#8211; &#8216;Coz your SVM knowledge is incomplete without it"}]},{"@type":"WebSite","@id":"https:\/\/techvidvan.com\/tutorials\/#website","url":"https:\/\/techvidvan.com\/tutorials\/","name":"TechVidvan Blogs","description":"","publisher":{"@id":"https:\/\/techvidvan.com\/tutorials\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/techvidvan.com\/tutorials\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/techvidvan.com\/tutorials\/#organization","name":"TechVidvan","url":"https:\/\/techvidvan.com\/tutorials\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/","url":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","contentUrl":"https:\/\/techvidvan.com\/tutorials\/wp-content\/uploads\/2024\/03\/techvidvan-logo-200x50-1.webp","width":200,"height":50,"caption":"TechVidvan"},"image":{"@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/TechVidvan\/","https:\/\/x.com\/vidvantech"]},{"@type":"Person","@id":"https:\/\/techvidvan.com\/tutorials\/#\/schema\/person\/e9c26e74dd3d87421f7ada9433b8cd22","name":"TechVidvan Team","description":"The TechVidvan Team delivers practical, beginner-friendly tutorials on programming, Java, Python, C++, DSA, AI, ML, data Science, Android, Flutter, MERN, Web Development, and technology. Our experts are here to help you upskill and excel in today\u2019s tech industry."}]}},"amp_enabled":true,"_links":{"self":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/77467","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/comments?post=77467"}],"version-history":[{"count":0,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/posts\/77467\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media\/77481"}],"wp:attachment":[{"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/media?parent=77467"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/categories?post=77467"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/techvidvan.com\/tutorials\/wp-json\/wp\/v2\/tags?post=77467"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}