annotool.classify
Interface SavableClassifier

All Superinterfaces:
Classifier

public interface SavableClassifier
extends Classifier

Savable classifier returns a model (an object of a Serializable class), so that the classifier may be persisted and loaded back to memory for use.

See Also:
Classifier

Method Summary
 int[] classifyUsingModel(java.lang.Object model, float[][] testingPatterns, double[] prob)
          Classifies the internal model using multiple testing patterns
 int classifyUsingModel(java.lang.Object model, float[] testingPattern, double[] prob)
          Classifies the internal model using one testing pattern
 java.lang.Object getModel()
          Gets the internal model from the classifier
 java.lang.Object loadModel(java.lang.String model_file_name)
          Loads a previously saved model back into the classifier.
 void saveModel(java.lang.Object trainedModel, java.lang.String model_file_name)
          Saves a specified model to a specified file
 void setModel(java.lang.Object model)
          Sets an internal model to be used by the classifier
 java.lang.Object trainingOnly(float[][] trainingpatterns, int[] trainingtargets)
          Trains and returns an internal model using a training set.
 
Methods inherited from interface annotool.classify.Classifier
classify, doesSupportProbability, setParameters
 

Method Detail

trainingOnly

java.lang.Object trainingOnly(float[][] trainingpatterns,
                              int[] trainingtargets)
                              throws java.lang.Exception
Trains and returns an internal model using a training set.

Parameters:
trainingpatterns - Pattern data to train the algorithm
trainingtargets - Targets for the training pattern
Returns:
Model created by the classifier
Throws:
java.lang.Exception - Optional, generic exception to be thrown

getModel

java.lang.Object getModel()
Gets the internal model from the classifier

Returns:
Model created by the classifier.

setModel

void setModel(java.lang.Object model)
              throws java.lang.Exception
Sets an internal model to be used by the classifier

Parameters:
model - Model to be used by the classifier
Throws:
java.lang.Exception - Exception thrown if model is incompatible

classifyUsingModel

int classifyUsingModel(java.lang.Object model,
                       float[] testingPattern,
                       double[] prob)
                       throws java.lang.Exception
Classifies the internal model using one testing pattern

Parameters:
model - Model to be used by the classifier
testingPattern - Pattern data to be classified
prob - Storage for probability result
Returns:
The prediction result
Throws:
java.lang.Exception - Exception thrown if model is incompatible

classifyUsingModel

int[] classifyUsingModel(java.lang.Object model,
                         float[][] testingPatterns,
                         double[] prob)
                         throws java.lang.Exception
Classifies the internal model using multiple testing patterns

Parameters:
model - Model to be used by the classifier
testingPatterns - Pattern data to be classified
prob - Storage for probability result
Returns:
Array of prediction results
Throws:
java.lang.Exception - Exception thrown if model is incompatible

saveModel

void saveModel(java.lang.Object trainedModel,
               java.lang.String model_file_name)
               throws java.io.IOException
Saves a specified model to a specified file

Parameters:
trainedModel - Trained model that is to be saved
model_file_name - Name of the file to be saved to
Throws:
java.lang.Exception - Exception thrown if model cannot be saved
java.io.IOException

loadModel

java.lang.Object loadModel(java.lang.String model_file_name)
                           throws java.io.IOException
Loads a previously saved model back into the classifier.

Parameters:
model_file_name - Name of the file to be loaded
Returns:
Model that was loaded
Throws:
java.lang.Exception - Exception thrown if file cannot be found
java.io.IOException