Hello all, I'm trying to develop a simple matlab code to do classification for me, i am aware that i can use svmclassify function in the matlab instead trying to write the code by myself, but i have to do this becuase it is part of my job goal. Here is the problem: I am training the data set using the svmtrain function from the matlab and then trying to classify the new data by using my own code. From what i understand the svmtrain matlab returning the alpha, support vector and bias value which i can use to satisfy the hyperplane equation sign(w.x + b) for the new data. So i calculated the w value with this equation w = sum(alpha*class label*support vector), now i have the w value. I also have the new data that i want to classify which i already know what is the class label. I'm doing this because i want to know whether my classifier is working or not. So i plug in the value and do the calculation, but it retun me the wrong class label for the new data. Can anyone check the code and help me if there is something that i miss out or do it wrongly. Attached is the code. Thanks for the help

Not familiar with the MATLAB package. But, looks like it should be dot(w,x) - bias instead of dot(w,x) + bias, if I recall correctly. EDIT Well, apparently not. Looks like you're using the equation from http://www.mathworks.com/help/toolbox/bioinfo/ref/svmclassify.html. In that case, I'd check to see that you're not somehow switching the two groups around; beyond that I'm afraid I'm not much help.

I'm sorry, I don't really understand. What do you mean by switching the two groups around. I'm stuck here for quite sometime, have been searching and trying. Still I didn't get any solution

I'm sorry, I don't really understand what you're trying to tell me. What do you mean by switching the two groups? I have been stuck here for few days. Been searching and trying, but still didn't found any solution

Oh, something stupid like if (sign(dot(w,x)+bias) > 0) { class = "versicolor"; } else { class = "virginica } (You might have a sign error) Sorry, it's the best I can come up with. If you can show me more code/data, PM me and I may be able to help you more.

I just had SVM as part of the Coursera/Stanford Univ. Machine Learning (ML) class. All the code is in Matlab/Octave. PM me if you want it. I can't post it here since it includes answers to homework problems.

To any trader who is a newcomer to machine learning (e.g., SVM) you might want to read this thread on stackexchange b/f getting started. http://quant.stackexchange.com/ques...-machine-learning-algorithms-to-stock-markets