<?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 Avirat Sharma  on Medium]]></title>
        <description><![CDATA[Stories by Avirat Sharma  on Medium]]></description>
        <link>https://medium.com/@avirats18?source=rss-998e2bfb7ac5------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*eu2JuTQRqunXCNs4Xf8hgA.jpeg</url>
            <title>Stories by Avirat Sharma  on Medium</title>
            <link>https://medium.com/@avirats18?source=rss-998e2bfb7ac5------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 04 Dec 2026 13:21:03 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@avirats18/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[Support Vector Machine in Machine Learning]]></title>
            <link>https://medium.com/@avirats18/support-vector-machine-in-machine-learning-ac95282895ea?source=rss-998e2bfb7ac5------2</link>
            <guid isPermaLink="false">https://medium.com/p/ac95282895ea</guid>
            <category><![CDATA[articles]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[support-vector-machine]]></category>
            <category><![CDATA[svm]]></category>
            <category><![CDATA[sklearn]]></category>
            <dc:creator><![CDATA[Avirat Sharma ]]></dc:creator>
            <pubDate>Sun, 27 Aug 2023 19:52:55 GMT</pubDate>
            <atom:updated>2023-08-27T19:52:55.376Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is Support Vector Machine?</strong></p><p><a href="https://scikit-learn.org/stable/modules/svm.html">Support Vector Machine</a> (SVM) is a supervised machine learning algorithm which can be used for both classification or regression challenges. However, it is mostly used in classification problems. In this algorithm, each data is plotted in n-dimensional space (where n is the number of features you have) with the value of each feature being the value of a particular coordinate. After that, we perform classification by locating the hyperplane which differentiates both the classes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/818/1*w6QRFNy4-enRAw4aVw3j3w.png" /></figure><p>Support vector machine is based on the concept of decision planes that define decision boundaries. A decision plane is one that separates between a set of objects with different class memberships. For example, in the figure mentioned below, there are objects which belong to either class Green or Red. The separating line defines a boundary on the right side of which all objects are Green and to the left of which all objects are Red. Any new object (white circle) falling to the right is labeled, i.e., classified, as Green (or classified as Red should it fall to the left of the separating line).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/606/1*nOPJIPC_evJwSz_FTMqMaw.png" /></figure><p>Support vector machines not only draw a line between two classes, but consider a region about the line of some given width</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/731/1*8QU5iY_xT6_A4Pn8kjF8Xg.png" /></figure><p>Another scenario, where it is clear that a full separation of the Green and Red objects would require a curve (which is more complex than a line). Classification tasks based on drawing separating lines to distinguish between objects of different class memberships are known as hyperplane classifiers. Support Vector Machines are particularly suited to handle such tasks.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/754/1*NxS-vr3215PuQg2uCTq10w.png" /></figure><h4>What is Hyperplane?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/836/1*JkbGloWSPOorIJeuaOKWcw.png" /></figure><p>The goal of Support Vector Machine is to find the hyperplane which separates these two objects or classes. Let us consider another figure which shows some of the possible hyperplanes which can help in separating or dividing the dataset. It is the choice of the best hyperplane which is also the goal. The best hyperplane is defined by the extent to which a maximum margin is left for both classes. The margin is the distance between the hyperplane and the closest point in the classification</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/612/1*-ioMQ5s_f70cwAkTOgD3SQ.png" /></figure><p>Let us consider two hyperplanes among all and then check the margins represented by M1 and M2. You will notice that margin M1 &gt; M2, so the choice of the hyperplane which separates the best one is the new plane between the green and blue planes</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/602/1*pT5DN1rv0pw0TOTLzS1Yvg.png" /></figure><h4>What is Support Vector in SVM?</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*J-um7XOk5VLSTlNVmEQywQ.png" /></figure><h4>Cost Function and Gradient Updates</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*AIfFAKB78MnTmp5mxM0JFg.png" /></figure><p>Now that we have the loss function, we take partial derivatives with respect to the weights to find the gradients. Using gradients, we can update our weights.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/778/1*eeTazpWPgasvqjm3pwMl4w.png" /><figcaption>Gradients</figcaption></figure><p>When there is no misclassification, i.e our model correctly predicts the class of our data point, we only have to update the gradient from the regularization parameter.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/616/1*trFLo8UqFDztJL52d4Y4mQ.png" /></figure><p>When there is a misclassification, i.e our model makes a mistake on the prediction of the class of our data point, we include the loss along with the regularization parameter to perform gradient update</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/815/1*aCIOr7i13a2KgS_Us9f9cg.png" /></figure><h4>How to tune <a href="https://scikit-learn.org/stable/modules/grid_search.html">Parameters</a> of SVM?</h4><p><strong>Kernel</strong>: Kernel in support vector machine is responsible for the transformation of the input data into the required format. Some of the kernels used in support vector machines are linear, polynomial and radial basis function (RBF). In order to create a non-linear hyperplane, we use RBF and Polynomial function, and for complex applications, you should use more advanced kernels to separate classes that are nonlinear in nature. With this transformation, you can obtain accurate classifiers.</p><p><strong>Regularization</strong>: Using the <a href="https://scikit-learn.org/stable/">Scikit-learn’s</a> C parameters and adjusting we can maintain regularization. C denotes a penalty parameter representing an error or any form of misclassification. This misclassification allows you to understand how much of the error is actually bearable. This helps you nullify the compensation between the misclassified term and the decision boundary. With a smaller C value, you obtain hyperplane of small margin and with a larger C value, hyperplane of larger value is obtained</p><p><strong>Gamma</strong>: Lower value of Gamma creates a loose fit of the training dataset. On the other hand, a high value of gamma allows the model to get fit more appropriately. A low value of gamma will only provide consideration to the nearby points for the calculation of a separate plane. However, the high value of gamma will consider all the data-points to calculate the final separation line.</p><h4>Do we need to tune parameters always??</h4><p>You do not need to tune parameter in all cases. There are inbuilt functions in sklearn tool kit which can be used</p><blockquote><strong>Tuning Hyperparameters</strong></blockquote><p><strong>The ‘C’ and ‘gamma’ hyperparameter</strong></p><p><strong>C</strong> is the parameter for the soft margin cost function, which controls the influence of each individual support vector. This process involves trading error penalty for stability. Small C tends to emphasize the margin while ignoring the outliers in the training data(Soft Margin), while large C may tend to overfit the training data(Hard Margin). Thus for a very large values we can cause overfitting of the model and for a very small value of C we can cause underfitting. Thus the value of C must be chosen in such a manner that it generalises the unseen data well.</p><p>The <strong>gamma</strong> parameter is the inverse of the standard deviation of the RBF kernel (Gaussian function), which is used as a similarity measure between two points. A small gamma value define a Gaussian function with a large variance. In this case, two points can be considered similar even if are far from each other. On the other hand, a large gamma value define a Gaussian function with a small variance and in this case, two points are considered similar just if they are close to each other</p><h4>Advantages and Disadvantages of Support Vector Machine</h4><p><strong><em>Advantages of SVM</em></strong></p><ul><li>SVM Classifiers offer good accuracy and perform faster prediction compared to Naïve Bayes algorithm.</li><li>SVM guarantees optimality due to the nature of Convex Optimization, the solution will always be global minimum not a local minimum. SVMcan be access it conveniently, be it from Python or Matlab.</li><li>SVM can be used for both linearly separable as well as non-linearly separable data. Linearly separable data is the hard margin however, non-linearly separable data poses a soft margin.</li><li>SVM provides compliance to the semi-supervised learning models as well. It can be implemented in both labelled and unlabelled data. The only thing it requires is a condition to the minimization problem which is known as the Transductive SVM.</li><li>Feature Mapping used to be complex with respect to computation of the overall training performance of the model. With the help of Kernel Trick, SVM can carry out the feature mapping using simple dot product.</li><li>SVM works well with a clear margin of separation and with high dimensional space.</li></ul><p><strong><em>Disadvantages of SVM</em></strong></p><ul><li>SVM is not at all capable of handling text structures. It leads to bad performance as it results in the loss of sequential information.</li><li>SVM is not suitable for large datasets because of its high training time and it also takes more time in training compared to Naïve Bayes.</li><li>SVM works poorly with overlapping classes and is also sensitive to the type of kernel used.</li><li>In cases where the number of features for each data point exceeds the number of training data samples , the SVM under performs</li></ul><h4>Applications of SVM in Real World</h4><p>Support vector machines depend on supervised learning algorithms. The main goal of using SVM is to classify unseen data correctly.</p><p>SVMs can be used to solve various real-world problems:</p><ul><li><strong>Face detection</strong> — SVM can be used to classify parts of the image as a face and non-face and create a square boundary around the face.</li><li><strong>Text and hypertext categorization</strong> — SVM allows text and hypertext categorization for both inductive and transductive models. It uses training data for classification of documents into different categories. It categorizes based on the score generated and then compares with the threshold value.</li><li><strong>Classification of images</strong> — SVMs enhances search accuracy for image classification. In comparison to the traditional query-based searching techniques, SVM provides better accuracy</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ac95282895ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>