Can SVM with polynomial kernel be used for binary classification - matlab

I want to use SVM with polynomial kernel for my binary classification problem? Can SVM with polynomial kernel be used for binary classification?

The Kernel Functions are independent from multi-class classification. There purpose is to transform non-linearly seperatable data into an higher dimensional feature space. This allows the SVM to learn non-linear decision boundaries. So, as stated before, the answer is yes. You can use the RBF for binary classification. SVMs are inherently binary classifiers.
It's interesting that you want to choose the Kernel Function before proper evaluation.
I'd recommend you to test all the functions and see which one performs best on your data. It's hard to determine this by simply viewing the data...depending on your dimensions.

Related

What is the difference between `fitclinear` and `fitcsvm`?

In MATLAB the documentation says fitclinear uses SVM or logistic regression and fitcsvm also is an SVM.
Also fitclinear is usually faster. Why?
What is the difference between both?
As stated in the description of fitclinear:
For reduced computation time on a high-dimensional data set that
includes many predictor variables, train a linear classification model
by using fitclinear. For low- through medium-dimensional predictor
data sets, see Alternatives for Lower-Dimensional Data.
fitcsvm is present among these alternatives for Lower-Dimensional Data.
In other words, fitclinear is best to be used with high-dimensional data, while fictsvm should be used for low through medium-dimensional predictor data sets.

why using precomputed kernels with libsvm in matlab

I am new to MATLAB and to LIBSVM. I got the fact that to use precomputed kernel, you must include sample serial number as the first column of the training and testing data. But importantly what I don't understand is: why would I use precomputed kernels? I am following the script described in LIBSVM and got results for linear and RBF but do not understand the need to use precomputed kernels.
Whether you need precomputed kernels depends on your metrics of input vectors. Sometimes you may need a different similarity function other than the norm-2 Euclidean distance or the radial basis function between a given feature to all the features from training set.
It is also possible that you need a multiplicative kernel (for example the product of two different kernel functions), which is not feasible by choosing one kernel type from Libsvm. Then writing a precomputed kernel is a good option.

Support Vector Machine vs K Nearest Neighbours

I have a data set to classify.By using KNN algo i am getting an accuracy of 90% but whereas by using SVM i just able to get over 70%. Is SVM not better than KNN. I know this might be stupid to ask but, what are the parameters for SVM which will give nearly approximate results as KNN algo. I am using libsvm package on matlab R2008
kNN and SVM represent different approaches to learning. Each approach implies different model for the underlying data.
SVM assumes there exist a hyper-plane seperating the data points (quite a restrictive assumption), while kNN attempts to approximate the underlying distribution of the data in a non-parametric fashion (crude approximation of parsen-window estimator).
You'll have to look at the specifics of your scenario to make a better decision as to what algorithm and configuration are best used.
It really depends on the dataset you are using. If you have something like the first line of this image ( http://scikit-learn.org/stable/_images/plot_classifier_comparison_1.png ) kNN will work really well and Linear SVM really badly.
If you want SVM to perform better you can use a Kernel based SVM like the one in the picture (it uses a rbf kernel).
If you are using scikit-learn for python you can play a bit with code here to see how to use the Kernel SVM http://scikit-learn.org/stable/modules/svm.html
kNN basically says "if you're close to coordinate x, then the classification will be similar to observed outcomes at x." In SVM, a close analog would be using a high-dimensional kernel with a "small" bandwidth parameter, since this will cause SVM to overfit more. That is, SVM will be closer to "if you're close to coordinate x, then the classification will be similar to those observed at x."
I recommend that you start with a Gaussian kernel and check the results for different parameters. From my own experience (which is, of course, focused on certain types of datasets, so your mileage may vary), tuned SVM outperforms tuned kNN.
Questions for you:
1) How are you selecting k in kNN?
2) What parameters have you tried for SVM?
3) Are you measuring accuracy in-sample or out-of-sample?

Matlab SVM training for muliclasses dataset

I have a question about the SVM MATLAB toolbox 2009b! the question is:
How I can train SVM classifier for classifying multi-classes datasets in MATLAB toolbox 2009b?
I just want to work with MATLAB toolbox, so please answer it if there is a way to implement it. For example, the below code is for classifying two classes datasets:
svmtrain( training data, ...
labels of training data, ...
'Kernel_Function', ...
'rbf', ...
'RBF_Sigma', ...
sigma value, ...
'Method', ...
'LS', ...
'BoxConstraint', ...
C ...
);
I want to know is there a way for training SVM for multi-classes dataset with writing a code such as above code, or should I write some code for training a SVM for each class versus the other classes?
It means, should I consider 1 for the label of the selected class and set the label of the other classes to 0, and train a SVM with above code, and do it for all classes!?
Thanks for your consideration :-)
I have not used SVM in Matlab, so other people can likely provide a more informed response, but I will share what I have learned.
Matlab Bioinformatics Toolbox SVM
From reading the documentation, the SVM in the Bioinformatics Toolbox appears to only support binary classification. As suggested in the question, a binary classifier can, with some effort, be used to classify into multiple classes. There is some discussion on approaches for doing this in the context of SVM here.
Alternate options
LIBSVM does support multi-class classification and comes with a Matlab interface. You could try installing and using it.
Additionally, while looking into this, I did come across several other Matlab toolboxes with SVM implementations. If LIBSVM is not a good option for you, it may be worth looking around to see if a different SVM implementation fits your needs.
If you have MATLAB release R2014b or later you can use the fitcecoc function in the Statistics and Machine Learning Toolbox to train a multi-class SVM.
Yup, the way for solving your problem - is to implement one vs all strategy. One of the SVM's lacks is that it has no direct multiclassification implementation.
But you can implement it through the binary classification.
I didn't see any function for svm multi classification in matlab. But i think it is not hard to implement it by yourself

feature selection using perceptron

Do you know an example that makes feature selection using a perceptron, maybe an implementation on matlab...
The perceptron is a binary linear classifier, that is, it can classify n-dimensional data that look like this:
but not like this:
into two distinct categories. Just like any other neural network, it first needs to be trained on a training set, and then only it can be used to classify new data points.
The perceptron can therefore be applied to classify any linearly separable dataset. A Matlab implementation is available in the Neural Network toolbox (see the documentation). An excellent toolbox for pattern recognition in general, with excellent classifiers, is PRTools, which is kind of the open source variant of the commercial toolbox PRSD Studio.