Multiclass classification in LabVIEW using SVM and one-vs-all method

Saturday, January 11th, 2014

As I mentioned in the last post, I am now studying machine learning in my new position. Today I came across a problem to use SVM to do multiclass classification. The toolkit (link) downloaded from NI did not provide the ability to do multiclass classification with SVM but only for two classes (it’s quite a useful tool still). So I took use of the SVM VIs and made a multiclass version using one-vs-all method.

There is a good tutorial on one-vs-all or one-vs-rest classification by Andrew Ng (link). So basically we pick one class each iteration as Class A and make the rest classes as Class B. Only the test data that locate in Class A are allocated to the known class. Here is the code:

SVM one-vs-all

The original trained labelled data are classified as Class 0, 1, 2, … N. In the i-th iteration, only the data from Class i are re-classified to Class 1 and the rest data are re-classified to Class 0. When the test data locate in class 1 area, they are classified as Class i. Any unsorted data are left in Class -1. When I test the performance of this one-vs-all classifier, the result seems fine 🙂

one-vs-all front panel

The code is not optimized and the execution may cost a while.


One comment on “Multiclass classification in LabVIEW using SVM and one-vs-all method

  1. Hello Dr. Fu

    Thanks for the explanation and sharing the code. I have a small doubt. According to Andrew Ng’s video, if there are N classes, N classifiers have to be trained and hence for a particular test data we receive N classifications and we must choose the classification with the highest probability. However, in your implementation, the maximization of the probability is missing. I think your implementation will work fine so long as you do not have outliers in your test data. If you have outliers two or more of the classifiers may give a false positive result and in that case it becomes important to look at the probability. Please correct me if I am wrong.

    Biswarup Mukherjee

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: