Question

I am new to ML and SVMs etc in general. I have an array of x,y data points of a signal. The signal resembles an ECG (below). I want to train the SVM to classify a normal ECG signal vs a non-normal (abnormal) signal. What is the best way to achieve this with LibSVM (or any other SVM library)?

ECG

Was it helpful?

Solution

Support Vector Machines like almost all classifiers require that the training samples are represented as feature vectors that lie in a feature space.

In order to create such feature vectors you'll have to do feature extraction to your signals. That is, you have to extract some measurable discriminating scale invariant features from your signals (e.g., wavelet coefficients).

Once you do that, you'll have to organize your feature vectors as the rows (or columns) of a data-matrix. A data-matrix is a 2D matrix where its rows (or its columns) are the feature vectors previously extracted. For example suppose that you have 3 signals that are represented by 3D feature vectors (i.e., from each one of your signals you've extracted 3 features).

enter image description here, enter image description here, enter image description here

(Where T denotes the transpose).

Then your data matrix would be:

enter image description here

After creating the data-matrix you'll have to create the vector of the data labels. Labels' vector is a 1D vector with the same number of rows (or columns) as your data matrix and contains the class labels corresponding to your feature vectors. Since your problem consists of two classes (i.e., normal and non-normal) your labels vector would have only 2 symbols (e.g., normal = -1, non-normal = 1). Continuing on the previous example if enter image description here normal and enter image description here non-normal, your labels vector would look like enter image description here

Now as far as it concerns the LibSVM part: LibSVM uses the LibSVM format to store the data matrix along with the class labels in a .txt file. The format of file is:

<label> <index1>:<value1> <index2>:<value2>

Following our example the contents of your file would look like:

-1 1:1 2:2 3:3
-1 1:4 2:5 3:6
 1 1:7 2:8 3:9

Have in mind though, that if you have zeroth values you can omit them. For example if enter image description here then your file would look like:

-1 2:2 3:3
-1 1:4 2:5 3:6
 1 1:7 2:8 3:9

Also notice that in each row of the file, first you write the class label of the feature vector and then its values.

Once you've created the file mentioned above, you are ready to go. In the LibSVM's site you'll find all the instructions need it to run LibSVM with your file.

OTHER TIPS

to me your problem sounds like a One-class classification problem as you will never have training samles for the "non-normal" feature space. libSVM does support that.

the tricky part is to extract invariant features which is a signal processing problem. you probably have to evaluate different approaches like wavelets, FFT or brute force sampling. you could also try to a descriptive approach like the 6 relative minimum/maximum values. algorithms covering multiple periods could be more stable than algorithms based on extracting single periods and/or extracting single parameters.

depending on your acceptable false positive and false negative rates some of the alternatives may be subject to exclusion.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top