|
GATE Version 3.1-2270 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectgate.creole.ml.svmlight.SVMLightWrapper
public class SVMLightWrapper
Wrapper class for the SVM Light support vector machine learning algorithm. The executable files, SVM_Learn and SVM_Classify must be placed on your path in order for this wrapper to work.
Nested Class Summary | |
---|---|
protected class |
SVMLightWrapper.LoadDatasetAction
This class adds the option to the context menu in the GUI that allows the user to load a dataset which is in SVM Light's own format from a file. |
protected class |
SVMLightWrapper.LoadModelAction
This reloads a file that was previously saved using the SaveModelAction class. |
protected class |
SVMLightWrapper.SaveDatasetAction
|
protected class |
SVMLightWrapper.SaveModelAction
This allows the model, including its parameters to be saved to a file. |
Field Summary | |
---|---|
protected List |
actionsList
|
protected boolean |
datasetChanged
Marks whether the dataset was changed since the last time the classifier was built. |
protected DatasetDefintion |
datasetDefinition
|
protected File |
modelFile
|
protected boolean |
modelTrained
Marks whether in the present state a trained model exists (whether or not it is up to date) |
protected HashMap |
nominalValue2IntegerHash
|
protected org.jdom.Element |
optionsElement
The JDom element contaning the options fro this wrapper. |
protected ProcessingResource |
owner
|
protected File |
resultsFile
|
protected StatusListener |
sListener
|
protected File |
testDataFile
|
protected List |
trainingData
This List stores all the data that has been collected. |
protected File |
trainingDataFile
These file objects store the path names to the files that will be used to store the model, data and results while they are passed to and from svm light. |
Constructor Summary | |
---|---|
SVMLightWrapper()
This constructor sets up action list so that these actions (loading and saving models and data) will be available from a context menu in the gui). |
Method Summary | |
---|---|
void |
addTrainingInstance(List attributeValues)
This is called to add a new training instance to the data set collected in this wrapper object. |
List |
batchClassifyInstances(List instances)
Decide on the outcomes for all the instances, based on the values of all the features for each of the instances in a document. |
Object |
classifyInstance(List attributeValues)
Decide on the outcome for the instance, based on the values of all the features. |
void |
cleanUp()
Delete all the temporary files when the processing resource is closed. |
List |
getActions()
Gets the list of actions that can be performed on this resource. |
DatasetDefintion |
getDatasetDefinition()
|
void |
init()
Initialises the classifier and prepares for running. |
void |
initialiseAndTrainClassifier()
Use svm_learn to create a new svm model, based on all the data currently stored in the wrapper. |
boolean |
isDatasetChanged()
Has the dataset changed since the model was last trained? |
boolean |
isModelTrained()
Is there a trained model available (whether or not it is up to date)? |
void |
load(InputStream is)
Loads the state of this engine from previously saved data. |
void |
loadDataset(FileReader reader)
Reads training data in SVM Light format from a file and adds it to the collection of training examples. |
void |
loadModel(File file)
Load a previously saved state of the engine. |
void |
save(OutputStream os)
Saves the state of the engine for reuse at a later time. optionsElement is not saved so as to make this code consistent with wekaWrapper. |
void |
saveDataset(FileWriter writer,
List dataSet)
Write the data set to a file in SVM Light format. |
void |
saveModel(File file)
Saves the state of the engine for reuse at a later time. optionsElement is not saved so as to make this code consistent with wekaWrapper. |
void |
setDatasetDefinition(DatasetDefintion definition)
Set the data set defition for this classifier. |
void |
setOptions(org.jdom.Element optionsElem)
Take a representation of the part of the XML configuration file which corresponds to <OPTIONS>, and store it. |
void |
setOwnerPR(ProcessingResource pr)
Registers the PR using the engine with the engine itself. |
boolean |
supportsBatchMode()
Returns true if the engine supports BatchMode, returns false otherwise. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected HashMap nominalValue2IntegerHash
protected DatasetDefintion datasetDefinition
protected List trainingData
protected org.jdom.Element optionsElement
protected boolean datasetChanged
protected boolean modelTrained
protected File trainingDataFile
protected File testDataFile
protected File modelFile
protected File resultsFile
protected List actionsList
protected ProcessingResource owner
protected StatusListener sListener
Constructor Detail |
---|
public SVMLightWrapper()
Method Detail |
---|
public void cleanUp()
cleanUp
in interface MLEngine
public void setOptions(org.jdom.Element optionsElem)
setOptions
in interface MLEngine
optionsElem
- the JDom element containing the options from the
configuration.
GateException
public void addTrainingInstance(List attributeValues)
addTrainingInstance
in interface MLEngine
attributeValues
- A list of String objects, each of which corresponds
to an attribute value. For boolean attributes the values will be true or
false.public void setDatasetDefinition(DatasetDefintion definition)
setDatasetDefinition
in interface MLEngine
definition
- A specification of the types and allowable values of
all the attributes, as specified in the <DATASET> part of the
configuration file.public Object classifyInstance(List attributeValues) throws ExecutionException
classifyInstance
in interface MLEngine
attributeValues
- A list of all the attributes, including the
<CLASS/> attribute. The value of the <CLASS/> attribute is,
however, arbitrary.
ExecutionException
public List batchClassifyInstances(List instances) throws ExecutionException
batchClassifyInstances
in interface MLEngine
attributeValues
- A list of lists of all the attributes, (one list
per instance) including the <CLASS/>attribute. The value of the
<CLASS/>attribute is, however, arbitrary.
ExecutionException
public void initialiseAndTrainClassifier() throws ExecutionException, IOException
ExecutionException
IOException
public void init() throws GateException
init
in interface MLEngine
GateException
- If it is not possible to initialise the classifier
for any reason.public List getActions()
getActions
in interface ActionsPublisher
public void setOwnerPR(ProcessingResource pr)
setOwnerPR
in interface MLEngine
pr
- the processing resource that owns this engine.public DatasetDefintion getDatasetDefinition()
public void saveDataset(FileWriter writer, List dataSet)
writer
- An open file writer to which the data is to be written.dataSet
- The data set to be saved, in the form of a list of
attributes in the form passed from the ML PR.public void loadDataset(FileReader reader) throws GateRuntimeException, IOException
reader
- A file reader from which to read the data.
GateRuntimeException
IOException
public void load(InputStream is) throws IOException
An
- open InputStream from which the model will be loaded.
IOException
public void save(OutputStream os) throws IOException
An
- open output stream to which the model will be saved.
IOException
public void loadModel(File file) throws IOException
file
- the file from which the state is to be loaded. If the state
indicates that a trained model should be loaded, this should be in
file.NativePart.
IOException
public void saveModel(File file) throws IOException
IOException
public boolean isDatasetChanged()
public boolean isModelTrained()
public boolean supportsBatchMode()
AdvancedMLEngine
supportsBatchMode
in interface AdvancedMLEngine
|
GATE Version 3.1-2270 |
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |