1

I want to classify a data set (which has four classes) using the SVM method. I've done it using the coding below (using a 1 against all). It isn't terribly accurate but I'm thankful for anything at this stage.

http://www.mathworks.co.uk/matlabcentral/fileexchange/39352-multi-class-svm

I was wondering if there is a way to plot the support vectors and training points. I've managed this for a 2 class SVM classification but can't find a way of doing it with >2 classes.

Here is an example as requested

Any help/advice re. how to achieve a semi-pretty graph would be very much appreciated!

Laura
  • 45
  • 2
  • 7
  • Can you post your code you used to plot and also maybe an example plot? – Dan Apr 24 '13 at 15:24
  • For a two class I think this is right: svmStruct = svmtrain(T,C,'showplot',true); classes = svmclassify(svmStruct,[1.5 15],'showplot',true). I'll paste an example in a moment... – Laura Apr 24 '13 at 15:35
  • @Laura: one idea is to generate a mesh grid over the entire space of features and classify each point in that grid, something similar to the one shown here: http://stackoverflow.com/a/1962535/97160 . Once you have that you can use `contour` function to draw the boundaries. Also you might be interested in another answer showing how to do multi-class SVM classification: http://stackoverflow.com/a/4980055/97160 – Amro Apr 24 '13 at 22:20
  • You say you're "thankful for anything at this stage", does this mean you started off from actually wanting to classify your data and tried SVMs or you had to use SVMs ? Because if you don't have to, then you might want to look at other classification methods that might be easier for you to implement (and possibly yielding higher accuracy) ;) – Dolma Apr 25 '13 at 16:12
  • Dolma - I have to use SVMs sadly. Alongside neural netowrks (RBF and MLP) and KNN. KNN was lovely and very amicable ;). I'm basically comparing the outputs of the whole lot of them, but like you say not using it would be optimal! @Armo Thanks very much for your links - I'll have a go at replicating the other method. :) – Laura Apr 26 '13 at 11:43
  • Well I didn't actually say that. SVMs are actually pretty good models, what I meant was that for good SVM models, the ratio (accuracy improvement)/(amount of work needed to understand and implement them) can sometimes be too small for it to be interesting. Have you already tried to implement your MLP model ? If not, I actually did this not so long ago on Matlab so I could give you some advice if you want ;) – Dolma Apr 26 '13 at 14:42
  • @Dolma I'm trying to use newff at the moment which is working to an extent. After training, the 'sim' produces 2000 columns of 4 values mostly between 0 and 1. I was after a class "1, 2, 3 or 4' i.e. a 1 in the appropriate class row, so I have no idea what's gone on or what I should be using to assign them to my target groups. No worries if you don't know, thanks again anyway :). – Laura Apr 29 '13 at 12:52
  • Oh ok, well I never used newff, mostly because I'm coding everything from scratch since I also implement more advanced neural network architectures which are not contained in any toolbox. But what it seems to me from what you say is that it's using some sort of sigmoid units for the output layer which would be the reason why you only get values between 0 and 1. What you get is the extent (probability) to which the input case is from a certain class. If you want to have a value of 1 in only 1 of the 4 rows and a value of 0 in the other 3 rows, you might want to look at softmax layers ;) – Dolma Apr 29 '13 at 13:15
  • Oh and if you have any questions or need more information on the subject, you could either post another question on the forum or even email me (I guess my address is displayed in my profile) because it's really not so practical here in the comments :p It took me some time to get used to these models so if I can help someone go a bit faster I'm glad I can ;) – Dolma Apr 29 '13 at 13:20
  • Thank you so much for explaining that and for your offer of further help. I shall have a look at the softmax stuff first though. Cheers again :) – Laura Apr 29 '13 at 13:29
  • You're welcome! And yeah, take all the time you need to grasp the concepts. Basically what a softmax unit does is make sure all your outputs sum up to 1 and they all represent the probability for this class to be "on". What you have to do from there is to put the greatest value to 1 and all the other values to 0 ;) (**Note:** The softmax alone won't do that, it just has the good properties needed for this to work properly) – Dolma Apr 29 '13 at 14:28
  • on the topic on ANN, let me just share these posts that might be of help here: http://stackoverflow.com/a/9049047/97160, http://stackoverflow.com/q/1291027/97160 – Amro May 03 '13 at 14:42

0 Answers0