-
Notifications
You must be signed in to change notification settings - Fork 13
Classifier Training
davidpicard edited this page May 25, 2012
·
1 revision
To train a classifier, you first need a list of training samples.
In order to be able to work on any type of input space, the datatype of the samples are encapsulated into a generic class called TrainingSample
. This class contains the sample of generic type T and the associated label (if the sample is labeled):
public class TrainingSample<T> implements Serializable {
T sample;
int label;
}
Training an SVM classifier consists in calling the method train with a list of TrainingSample as parameters. For example, A SVM with GaussianKernel on vectors of double would be done as follows:
List<TrainingSample<double[]>> train = new ArrayList<TrainingSample<double[]>>();
/* here goes the code where you feed the list with labeled samples */
DoubleGaussL2 k = new DoubleGaussL2();
LaSVM<double[]> lasvm = new LaSVM<double[]>(k);
lasvm.train(train);
In this example, the evaluation of a new sample is as simple as:
double[] sample;
// filling sample
double value = lasvm.valueOf(sample);