We will understand the SVM training and testing models in R and look at the main functions of e package i. The first and most intuitive package is the e package. With the svm function, we achieve a rigid interface in the libsvm by using visualization and parameter tuning methods. Refer some of the features of libsvm library given below: Offers quick and easy implementation of SVMs. Provides most common kernels, including linear, polynomial, RBF, and sigmoid.

Author:Dainris Taubar
Language:English (Spanish)
Published (Last):5 August 2016
PDF File Size:9.20 Mb
ePub File Size:12.44 Mb
Price:Free* [*Free Regsitration Required]

We will first do a simple linear regression, then move to the Support Vector Regression so that you can see how the two behave with the same data. A simple data set To begin with we will use this simple data set: I just put some data in excel. I prefer that over using an existing well-known data-set because the purpose of the article is not about the data, but more about the models we will use.

As you can see there seems to be some kind of relation between our two variables X and Y, and it look like we could fit a line which would pass near each point. In order to be able to compare the linear regression with the support vector regression we first need a way to measure how good it is. The only difference with the previous graph is that the dots are not connected with each other. We can compare each value with the associated predicted value and see how far away they are with a simple difference.

Note that the expression is the error, if we make a perfect prediction will be equal to and the error will be zero. Note that we called the svm function not svr! But can we do better? Step 4: Tuning your support vector regression model In order to improve the performance of the support vector regression we will need to select the best parameters for the model.

In our previous example, we performed an epsilon-regression, we did not set any value for epsilon , but it took a default value of 0. There is also a cost parameter which we can change to avoid overfitting. The process of choosing these parameters is called hyperparameter optimization , or model selection. The standard way of doing it is by doing a grid search. The last line plot the result of the grid search: On this graph we can see that the darker the region is the better our model is because the RMSE is closer to zero in darker regions.

This means we can try another grid search in a narrower range we will try with values between 0 and 0. It does not look like the cost value is having an effect for the moment so we will keep it as it is to see if it changes.

As we zoomed-in inside the dark region we can see that there is several darker patch. From the graph you can see that models with C between and and between 0. If we want we can visualize both our models. Each step has its own file. I like to explain things simply to share my knowledge with people from around the world.

If you wish you can add me to linkedin, I like to connect with my readers.


SVM example with Iris Data in R



Support Vector Regression with R



e1071 Package – Perfect Guide on SVM Training & Testing Models in R




Related Articles