hhreco.classification
Class SVMClassifier

java.lang.Object
  extended byhhreco.classification.SVMClassifier
All Implemented Interfaces:
Classifier, TrainableClassifier

public class SVMClassifier
extends java.lang.Object
implements TrainableClassifier

This class uses libsvm, a SVM software library written in Java, to do SVM classification. [1]

[1]Chih-Chung Chang and Chih-Jen Lin http://www.csie.ntu.edu.tw/~cjlin/libsvm


Constructor Summary
SVMClassifier(boolean normalizeScale)
          Create a SVM Classifier with default parameters and specify whether the data needs to be scaled.
SVMClassifier(boolean normalizeScale, libsvm.svm_parameter p)
          Create a SVM Classifier, specify whether the data needs to be scaled, and use the given set of parameters for the SVM classifier.
 
Method Summary
 Classification classify(FeatureSet fs)
          Classify the given example using SVM.
 void clear()
          Clear all results of previous trainings (presumably so that this classifier can be trained again from scratch).
static libsvm.svm_parameter defaultSVMParam()
          Set up the default set of parameters for the SVM classifier.
 boolean isIncremental()
          Not an incremental classifier.
 FeatureSet scale(FeatureSet fvals)
          Scale the given feature vector based on the scale obtained from the training set.
 TrainingSet scale(TrainingSet tset, int min, int max)
          Scale the feature values in the training set to be in the range of [min,max].
 void train(TrainingSet tset, int numFeatures)
          Convert TraininSet examples into libsvm data structure, build a svm_problem object for the training set, and call svm_train to compute the svm model.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SVMClassifier

public SVMClassifier(boolean normalizeScale)
Create a SVM Classifier with default parameters and specify whether the data needs to be scaled.


SVMClassifier

public SVMClassifier(boolean normalizeScale,
                     libsvm.svm_parameter p)
Create a SVM Classifier, specify whether the data needs to be scaled, and use the given set of parameters for the SVM classifier.

Method Detail

classify

public Classification classify(FeatureSet fs)
                        throws ClassifierException
Classify the given example using SVM.

Specified by:
classify in interface Classifier
Throws:
ClassifierException

train

public void train(TrainingSet tset,
                  int numFeatures)
           throws ClassifierException
Convert TraininSet examples into libsvm data structure, build a svm_problem object for the training set, and call svm_train to compute the svm model. If scaling is indicated, this method will scale the data values to be in the range of 0 and 1.

Specified by:
train in interface TrainableClassifier
Throws:
ClassifierException

defaultSVMParam

public static libsvm.svm_parameter defaultSVMParam()
Set up the default set of parameters for the SVM classifier.


scale

public FeatureSet scale(FeatureSet fvals)
Scale the given feature vector based on the scale obtained from the training set. This method is called by classify to scale the test example.


scale

public TrainingSet scale(TrainingSet tset,
                         int min,
                         int max)
Scale the feature values in the training set to be in the range of [min,max].


isIncremental

public boolean isIncremental()
Not an incremental classifier. Calls to train will remove the original training data and retrain the classifier with the new set.

Specified by:
isIncremental in interface TrainableClassifier

clear

public void clear()
Description copied from interface: TrainableClassifier
Clear all results of previous trainings (presumably so that this classifier can be trained again from scratch).

Specified by:
clear in interface TrainableClassifier