gate.creole.ml.weka
Class Wrapper

java.lang.Object
  |
  +--gate.creole.ml.weka.Wrapper
All Implemented Interfaces:
ActionsPublisher, MLEngine

public class Wrapper
extends Object
implements MLEngine, ActionsPublisher

Wrapper class for the WEKA Machine Learning Engine.


Nested Class Summary
protected  class Wrapper.LoadModelAction
           
protected  class Wrapper.SaveDatasetAsArffAction
           
protected  class Wrapper.SaveModelAction
           
 
Field Summary
protected  List actionsList
           
protected  weka.classifiers.Classifier classifier
          The WEKA classifier used by this wrapper
(package private)  double confidenceThreshold
           
protected  weka.core.Instances dataset
          The dataset used for training
protected  boolean datasetChanged
          Marks whether the dataset was changed since the last time the classifier was built.
protected  DatasetDefintion datasetDefinition
           
protected  org.jdom.Element optionsElement
          The JDom element contaning the options fro this wrapper.
protected  ProcessingResource owner
           
protected  StatusListener sListener
           
 
Constructor Summary
Wrapper()
           
 
Method Summary
 void addTrainingInstance(List attributeValues)
          Adds a new training instance to the dataset.
protected  weka.core.Instance buildInstance(List attributeValues)
          Constructs an instance valid for the current dataset from a list of attribute values.
 Object classifyInstance(List attributeValues)
          Classifies a new instance.
protected  Object convertAttributeValue(double value)
           
 List getActions()
          Gets the list of actions that can be performed on this resource.
 void init()
          Initialises the classifier and prepares for running.
protected  void load(InputStream is)
          Loads the state of this engine from previously saved data.
protected  void save(OutputStream os)
          Saves the state of the engine for reuse at a later time.
 void setDatasetDefinition(DatasetDefintion definition)
          Sets the definition for the dataset used.
 void setOptions(org.jdom.Element optionsElem)
          Sets the options from an XML JDom element.
 void setOwnerPR(ProcessingResource pr)
          Registers the PR using the engine with the engine itself.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

datasetDefinition

protected DatasetDefintion datasetDefinition

confidenceThreshold

double confidenceThreshold

classifier

protected weka.classifiers.Classifier classifier
The WEKA classifier used by this wrapper


dataset

protected weka.core.Instances dataset
The dataset used for training


optionsElement

protected org.jdom.Element optionsElement
The JDom element contaning the options fro this wrapper.


datasetChanged

protected boolean datasetChanged
Marks whether the dataset was changed since the last time the classifier was built.


actionsList

protected List actionsList

owner

protected ProcessingResource owner

sListener

protected StatusListener sListener
Constructor Detail

Wrapper

public Wrapper()
Method Detail

setOptions

public void setOptions(org.jdom.Element optionsElem)
Description copied from interface: MLEngine
Sets the options from an XML JDom element.

Specified by:
setOptions in interface MLEngine
Parameters:
optionsElem - the JDom element containing the options from the configuration.

addTrainingInstance

public void addTrainingInstance(List attributeValues)
                         throws ExecutionException
Description copied from interface: MLEngine
Adds a new training instance to the dataset.

Specified by:
addTrainingInstance in interface MLEngine
Parameters:
attributeValues - the list of attributes describing the instance. The elements in the list are String values that need to be interpreted according to the dataset definition: for nominal attributes the values will used as they are; for numeric attributes the values will be converted to double.
ExecutionException

buildInstance

protected weka.core.Instance buildInstance(List attributeValues)
                                    throws ExecutionException
Constructs an instance valid for the current dataset from a list of attribute values.

Parameters:
attributeValues - the values for the attributes.
Returns:
an Instance value.
ExecutionException

setDatasetDefinition

public void setDatasetDefinition(DatasetDefintion definition)
Description copied from interface: MLEngine
Sets the definition for the dataset used.

Specified by:
setDatasetDefinition in interface MLEngine
Parameters:
definition -

classifyInstance

public Object classifyInstance(List attributeValues)
                        throws ExecutionException
Description copied from interface: MLEngine
Classifies a new instance.

Specified by:
classifyInstance in interface MLEngine
Parameters:
attributeValues - the list of attributes describing the instance. The elements in the list are Object values that need to be interpreted according to the dataset definition. The value for the class element will be arbitrary.
Returns:
a String value for nominal and boolean attributes and a Double value for numeric attributes.
ExecutionException

convertAttributeValue

protected Object convertAttributeValue(double value)

init

public void init()
          throws GateException
Initialises the classifier and prepares for running.

Specified by:
init in interface MLEngine
Throws:
GateException

load

protected void load(InputStream is)
             throws IOException
Loads the state of this engine from previously saved data.

Parameters:
is -
IOException

save

protected void save(OutputStream os)
             throws IOException
Saves the state of the engine for reuse at a later time.

Parameters:
os -
IOException

getActions

public List getActions()
Gets the list of actions that can be performed on this resource.

Specified by:
getActions in interface ActionsPublisher
Returns:
a List of Action objects (or null values)

setOwnerPR

public void setOwnerPR(ProcessingResource pr)
Registers the PR using the engine with the engine itself.

Specified by:
setOwnerPR in interface MLEngine
Parameters:
pr - the processing resource that owns this engine.