OBJECT - The object being annotatedANNOTATION - The type of the annotationpublic class SVMAnnotator<OBJECT,ANNOTATION> extends BatchAnnotator<OBJECT,ANNOTATION>
| Modifier and Type | Field and Description |
|---|---|
HashMap<Integer,ANNOTATION> |
classMap
Stores the mapping between the positive and negative class and the annotation
|
static int |
NEGATIVE_CLASS
The input to the SVM model for negative classes
|
static int |
POSITIVE_CLASS
The input to the SVM model for positive classes
|
| Constructor and Description |
|---|
SVMAnnotator(FeatureExtractor<? extends FeatureVector,OBJECT> extractor)
Constructor that takes the feature extractor to use.
|
| Modifier and Type | Method and Description |
|---|---|
List<ScoredAnnotation<ANNOTATION>> |
annotate(OBJECT object)
Generate annotations for the given object.
|
double |
crossValidation(List<? extends Annotated<OBJECT,ANNOTATION>> data,
int numFold)
Performs cross-validation on the SVM.
|
static double |
crossValidation(libsvm.svm_problem prob,
libsvm.svm_parameter param,
int numFold)
Performs cross-validation on the SVM.
|
Set<ANNOTATION> |
getAnnotations() |
void |
loadModel(File loadModel)
Load an existing svm model.
|
void |
setSaveModel(File saveModel)
Set whether to save the SVM model to disk.
|
void |
train(List<? extends Annotated<OBJECT,ANNOTATION>> data)
Train the object with the given data.
|
trainclassifypublic static final int POSITIVE_CLASS
public static final int NEGATIVE_CLASS
public HashMap<Integer,ANNOTATION> classMap
public SVMAnnotator(FeatureExtractor<? extends FeatureVector,OBJECT> extractor)
extractor - The feature extractorpublic void train(List<? extends Annotated<OBJECT,ANNOTATION>> data)
BatchTrainers should reset the underlying
model everytime this method is called.data - the training dataBatchTrainer.train(java.util.List)public Set<ANNOTATION> getAnnotations()
Set of all annotations this Annotator knows
aboutAnnotator.getAnnotations()public List<ScoredAnnotation<ANNOTATION>> annotate(OBJECT object)
object - the imageAnnotator.annotate(java.lang.Object)public void setSaveModel(File saveModel)
saveModel - The file name to save to, or null to disable saving.public void loadModel(File loadModel) throws IOException
loadModel - The model to load fromIOException - If the loading does not completepublic double crossValidation(List<? extends Annotated<OBJECT,ANNOTATION>> data, int numFold)
data - The datanumFold - The number of foldspublic static double crossValidation(libsvm.svm_problem prob, libsvm.svm_parameter param, int numFold)
prob - The problemparam - The parametersnumFold - The number of folds