Bidski
Bidski

Reputation: 535

Encog SVM won't train

I am trying to train a SVM to classify two spiral data.

My input is a 3 column CSV file, the first two columns are the (x, y)-coordinates of a point on a spiral (not normalised) and the third column is the spiral (class) that the point belongs to.

I first normalise the CSV file so that the first two columns are between 0 and 1 (third column remains unchanged).

Then I create and train an SVM as follows

    CSVNeuralDataSet trainingSet = new CSVNeuralDataSer(normaliseCSV("/path/to/data/file"), 2, 1, false);

SVM svm = new SVM(2, false);

final SVMSearchTrain train = new SVMSearchTrain(svm, trainingSet);

int epoch = 0;

do {
  train.iteration();
  System.out.println("Epoch $: " + epoch + " Error: " + train.getError());
  epoch++;
} while(train.getError() > 0.01);

train.finishTraining();

However, the do...while loop ends up being an infinite loop as the training error is around 0.4 and it never changes.

The data set contains around 200 samples and there are only two classes (0 and 1).

Can anyone tell me why this is failing?

EDIT: Here is a pastebin link to roughly 10% of the training data.

Upvotes: 2

Views: 255

Answers (1)

Yuriy Zaletskyy
Yuriy Zaletskyy

Reputation: 5151

Wonderful question. Your problem is that SVM can't built separation curve for spiral data. I propose you to try normalization trick, but normalize not according to X, Y coordinates as straight lines, but switch to polar system of coordinates. And consider probably Archimedean spiral, logarithmic spiral, etc. enter image description here. Please look at picture. Spiral data require from SVM to built some function which will separate data between Class 1 and Class 2, and I'm pretty sure that it is not easy task for SVM. But if you will find way to switch from spiral data representation to linear, then SVM will need to built separation between two curves, which is much easier.

Upvotes: 2

Related Questions