weka.core
Class SetupGenerator

java.lang.Object
  extended by weka.core.SetupGenerator
All Implemented Interfaces:
Serializable, weka.core.OptionHandler

public class SetupGenerator
extends Object
implements Serializable, weka.core.OptionHandler

Generates different setups of objects (e.g., classifiers or filters) based on parameter settings. The parameter settings can be either based on mathematical functions; therefore numeric) or chosen from lists (for string values, SelectedTags or classnames (with optional parameters).

Version:
$Revision: 4521 $
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
Serialized Form

Field Summary
protected  Serializable m_BaseObject
          base object.
protected  boolean m_Initialized
          whether everything has been initialized.
protected  AbstractParameter[] m_Parameters
          the parameters.
protected  Space m_Space
          the parameter space to use for obtaining the setups from.
static weka.core.Tag[] TAGS_TYPE
          type of parameter.
static int TYPE_FUNCTION
          type: mathematical function.
static int TYPE_LIST
          type: explicit, comma-separated list of values.
 
Constructor Summary
SetupGenerator()
          Default constructor.
 
Method Summary
 String baseObjectFileTipText()
          Returns the tip text for this property.
protected  Serializable copy(Serializable obj)
          Returns a copy of the object.
 Point<Object> evaluate(Point<Object> values)
          evalutes the expression for the current iteration.
 Serializable getBaseObject()
          Returns the base object.
 String[] getOptions()
          returns the options of the current setup.
 AbstractParameter[] getParameters()
          Returns the current parameters.
 Space getSpace()
          Returns the space currently in use.
 String globalInfo()
          Returns a string describing the object.
protected  void initialize()
          Performs all the necessary initializations.
 Enumeration listOptions()
          Gets an enumeration describing the available options.
static void main(String[] args)
          For testing only.
 String parametersFileTipText()
          Returns the tip text for this property.
 void reset()
          Resets the generation.
 void setBaseObject(Serializable obj)
          Sets the base object, can be single object or array of objects.
 void setOptions(String[] options)
          Parses the options for this object.
 void setParameters(AbstractParameter[] value)
          Sets the parameters to use as basis for the setups.
 void setSpace(Space value)
          Updates the space to use for the setup generation.
 Serializable setup(Serializable original, Point<Object> values)
          returns a fully configures object (a copy of the provided one).
 Enumeration<Serializable> setups()
          Returns an enumeration of all the setups.
 Object setValue(Object o, String path, Object value)
          tries to set the value as double, integer (just casts it to int!) or boolean (false if 0, otherwise true) in the object according to the specified path.
 String toString()
          A string representation of the generator.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

TYPE_FUNCTION

public static final int TYPE_FUNCTION
type: mathematical function.

See Also:
Constant Field Values

TYPE_LIST

public static final int TYPE_LIST
type: explicit, comma-separated list of values.

See Also:
Constant Field Values

TAGS_TYPE

public static final weka.core.Tag[] TAGS_TYPE
type of parameter.


m_BaseObject

protected Serializable m_BaseObject
base object.


m_Parameters

protected AbstractParameter[] m_Parameters
the parameters.


m_Initialized

protected boolean m_Initialized
whether everything has been initialized.


m_Space

protected Space m_Space
the parameter space to use for obtaining the setups from.

Constructor Detail

SetupGenerator

public SetupGenerator()
Default constructor.

Method Detail

globalInfo

public String globalInfo()
Returns a string describing the object.

Returns:
a description suitable for displaying in the explorer/experimenter gui

listOptions

public Enumeration listOptions()
Gets an enumeration describing the available options.

Specified by:
listOptions in interface weka.core.OptionHandler
Returns:
an enumeration of all the available options.

getOptions

public String[] getOptions()
returns the options of the current setup.

Specified by:
getOptions in interface weka.core.OptionHandler
Returns:
the current options

setOptions

public void setOptions(String[] options)
                throws Exception
Parses the options for this object.

Specified by:
setOptions in interface weka.core.OptionHandler
Parameters:
options - the options to use
Throws:
Exception - if setting of options fails

baseObjectFileTipText

public String baseObjectFileTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setBaseObject

public void setBaseObject(Serializable obj)
Sets the base object, can be single object or array of objects.

Parameters:
obj - the object

getBaseObject

public Serializable getBaseObject()
Returns the base object.

Returns:
the object

parametersFileTipText

public String parametersFileTipText()
Returns the tip text for this property.

Returns:
tip text for this property suitable for displaying in the explorer/experimenter gui

setParameters

public void setParameters(AbstractParameter[] value)
Sets the parameters to use as basis for the setups.

Parameters:
value - the parameters

getParameters

public AbstractParameter[] getParameters()
Returns the current parameters.

Returns:
the parameters

reset

public void reset()
Resets the generation.


setSpace

public void setSpace(Space value)
Updates the space to use for the setup generation.

Parameters:
value - the space to use

getSpace

public Space getSpace()
Returns the space currently in use.

Returns:
the space

initialize

protected void initialize()
Performs all the necessary initializations.


evaluate

public Point<Object> evaluate(Point<Object> values)
evalutes the expression for the current iteration.

Parameters:
values - the current iteration values (from 'min' to 'max' with stepsize 'step') for all dimensions
Returns:
the generated value, NaN if the evaluation fails

setValue

public Object setValue(Object o,
                       String path,
                       Object value)
                throws Exception
tries to set the value as double, integer (just casts it to int!) or boolean (false if 0, otherwise true) in the object according to the specified path. float, char and long are also supported.

Parameters:
o - the object to modify
path - the property path
value - the value to set
Returns:
the modified object
Throws:
Exception - if neither double nor int could be set

setup

public Serializable setup(Serializable original,
                          Point<Object> values)
                   throws Exception
returns a fully configures object (a copy of the provided one).

Parameters:
original - the object to create a copy from and set the parameters
values - the current iteration values in all dimensions
Returns:
the configured classifier
Throws:
Exception - if setup fails

copy

protected Serializable copy(Serializable obj)
                     throws Exception
Returns a copy of the object.

Parameters:
obj - the object to copy
Returns:
the copy
Throws:
Exception - if copying fails

setups

public Enumeration<Serializable> setups()
Returns an enumeration of all the setups.

Returns:
the generated setups, null in case a setup could not be generated

toString

public String toString()
A string representation of the generator.

Overrides:
toString in class Object
Returns:
a string representation

main

public static void main(String[] args)
                 throws Exception
For testing only.

Parameters:
args - ignored
Throws:
Exception - if something goes wrong


Copyright © 2012 University of Waikato, Hamilton, NZ. All Rights Reserved.