// Switch on some debugging output
tp.getLearningParameters().verbosity = 1;
System.out.println("\nTRAINING SVM-light MODEL ..");
SVMLightModel model = trainer.trainModel(traindata, tp);
System.out.println(" DONE.");
// Use this to store a model to a file or read a model from a URL.
model.writeModelToFile("jni_model.dat");
model = SVMLightModel.readSVMLightModelFromURL(new java.io.File("jni_model.dat").toURL());
// Use the classifier on the randomly created feature vectors
System.out.println("\nVALIDATING SVM-light MODEL in Java..");
int precision = 0;
for (int i = 0; i < N; i++) {
// Classify a test vector using the Java object
// (in a real application, this should not be one of the training vectors)
double d = model.classify(traindata[i]);
if ((traindata[i].getLabel() < 0 && d < 0)
|| (traindata[i].getLabel() > 0 && d > 0)) {
precision++;
}
if (i % 10 == 0) {