Class Expression
- java.lang.Object
-
- weka.datagenerators.DataGenerator
-
- weka.datagenerators.RegressionGenerator
-
- weka.datagenerators.classifiers.regression.MexicanHat
-
- weka.datagenerators.classifiers.regression.Expression
-
- All Implemented Interfaces:
java.io.Serializable,OptionHandler,Randomizable,RevisionHandler
public class Expression extends MexicanHat
A data generator for generating y according to a given expression out of randomly generated x.
E.g., the mexican hat can be generated like this:
sin(abs(a1)) / abs(a1)
In addition to this function, the amplitude can be changed and gaussian noise can be added. Valid options are:-h Prints this help.
-o <file> The name of the output file, otherwise the generated data is printed to stdout.
-r <name> The name of the relation.
-d Whether to print debug informations.
-S The seed for random function (default 1)
-n <num> The number of examples to generate (default 100)
-A <num> The amplitude multiplier (default 1.0).
-R <num>..<num> The range x is randomly drawn from (default -10.0..10.0).
-N <num> The noise rate (default 0.0).
-V <num> The noise variance (default 1.0).
-E <expression> The expression to use for generating y out of x (default sin(abs(a1)) / abs(a1)).
- Version:
- $Revision: 1.5 $
- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
AddExpression,MexicanHat, Serialized Form
-
-
Constructor Summary
Constructors Constructor Description Expression()initializes the generator
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description java.lang.StringamplitudeTipText()Returns the tip text for this propertyInstancesdefineDataFormat()Initializes the format for the dataset produced.java.lang.StringexpressionTipText()Returns the tip text for this propertyInstancegenerateExample()Generates one example of the dataset.InstancesgenerateExamples()Generates all examples of the dataset.java.lang.StringgenerateFinished()Generates a comment string that documentats the data generator.java.lang.StringgenerateStart()Generates a comment string that documentates the data generator.java.lang.StringgetExpression()Gets the mathematical expression for generating y out of xjava.lang.String[]getOptions()Gets the current settings of the datagenerator BIRCHCluster.java.lang.StringgetRevision()Returns the revision string.booleangetSingleModeFlag()Return if single mode is set for the given data generator mode depends on option setting and or generator type.java.lang.StringglobalInfo()Returns a string describing this data generator.java.util.EnumerationlistOptions()Returns an enumeration describing the available options.static voidmain(java.lang.String[] args)Main method for testing this class.voidsetExpression(java.lang.String value)Sets the mathematical expression to generate y out of x.voidsetOptions(java.lang.String[] options)Parses a list of options for this object.-
Methods inherited from class weka.datagenerators.classifiers.regression.MexicanHat
getAmplitude, getMaxRange, getMinRange, getNoiseRate, getNoiseVariance, maxRangeTipText, minRangeTipText, noiseRateTipText, noiseVarianceTipText, setAmplitude, setMaxRange, setMinRange, setNoiseRate, setNoiseVariance
-
Methods inherited from class weka.datagenerators.RegressionGenerator
getNumExamples, numExamplesTipText, setNumExamples
-
Methods inherited from class weka.datagenerators.DataGenerator
debugTipText, defaultOutput, formatTipText, getDatasetFormat, getDebug, getNumExamplesAct, getOutput, getRandom, getRelationName, getSeed, makeData, outputTipText, randomTipText, relationNameTipText, seedTipText, setDatasetFormat, setDebug, setOutput, setRandom, setRelationName, setSeed
-
-
-
-
Method Detail
-
globalInfo
public java.lang.String globalInfo()
Returns a string describing this data generator.- Overrides:
globalInfoin classMexicanHat- Returns:
- a description of the data generator suitable for displaying in the explorer/experimenter gui
-
listOptions
public java.util.Enumeration listOptions()
Returns an enumeration describing the available options.- Specified by:
listOptionsin interfaceOptionHandler- Overrides:
listOptionsin classMexicanHat- Returns:
- an enumeration of all the available options
-
setOptions
public void setOptions(java.lang.String[] options) throws java.lang.ExceptionParses a list of options for this object. Valid options are:-h Prints this help.
-o <file> The name of the output file, otherwise the generated data is printed to stdout.
-r <name> The name of the relation.
-d Whether to print debug informations.
-S The seed for random function (default 1)
-n <num> The number of examples to generate (default 100)
-A <num> The amplitude multiplier (default 1.0).
-R <num>..<num> The range x is randomly drawn from (default -10.0..10.0).
-N <num> The noise rate (default 0.0).
-V <num> The noise variance (default 1.0).
-E <expression> The expression to use for generating y out of x (default sin(abs(a1)) / abs(a1)).
- Specified by:
setOptionsin interfaceOptionHandler- Overrides:
setOptionsin classMexicanHat- Parameters:
options- the list of options as an array of strings- Throws:
java.lang.Exception- if an option is not supported
-
getOptions
public java.lang.String[] getOptions()
Gets the current settings of the datagenerator BIRCHCluster.- Specified by:
getOptionsin interfaceOptionHandler- Overrides:
getOptionsin classMexicanHat- Returns:
- an array of strings suitable for passing to setOptions
- See Also:
DataGenerator.removeBlacklist(String[])
-
amplitudeTipText
public java.lang.String amplitudeTipText()
Returns the tip text for this property- Overrides:
amplitudeTipTextin classMexicanHat- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getExpression
public java.lang.String getExpression()
Gets the mathematical expression for generating y out of x- Returns:
- the expression for computing y
-
setExpression
public void setExpression(java.lang.String value)
Sets the mathematical expression to generate y out of x.- Parameters:
value- the expression for computing y
-
expressionTipText
public java.lang.String expressionTipText()
Returns the tip text for this property- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getSingleModeFlag
public boolean getSingleModeFlag() throws java.lang.ExceptionReturn if single mode is set for the given data generator mode depends on option setting and or generator type.- Overrides:
getSingleModeFlagin classMexicanHat- Returns:
- single mode flag
- Throws:
java.lang.Exception- if mode is not set yet
-
defineDataFormat
public Instances defineDataFormat() throws java.lang.Exception
Initializes the format for the dataset produced. Must be called before the generateExample or generateExamples methods are used. Re-initializes the random number generator with the given seed.- Overrides:
defineDataFormatin classMexicanHat- Returns:
- the format for the dataset
- Throws:
java.lang.Exception- if the generating of the format failed- See Also:
DataGenerator.getSeed()
-
generateExample
public Instance generateExample() throws java.lang.Exception
Generates one example of the dataset.- Overrides:
generateExamplein classMexicanHat- Returns:
- the generated example
- Throws:
java.lang.Exception- if the format of the dataset is not yet definedjava.lang.Exception- if the generator only works with generateExamples which means in non single mode
-
generateExamples
public Instances generateExamples() throws java.lang.Exception
Generates all examples of the dataset. Re-initializes the random number generator with the given seed, before generating instances.- Overrides:
generateExamplesin classMexicanHat- Returns:
- the generated dataset
- Throws:
java.lang.Exception- if the format of the dataset is not yet definedjava.lang.Exception- if the generator only works with generateExample, which means in single mode- See Also:
DataGenerator.getSeed()
-
generateStart
public java.lang.String generateStart()
Generates a comment string that documentates the data generator. By default this string is added at the beginning of the produced output as ARFF file type, next after the options.- Overrides:
generateStartin classMexicanHat- Returns:
- string contains info about the generated rules
-
generateFinished
public java.lang.String generateFinished() throws java.lang.ExceptionGenerates a comment string that documentats the data generator. By default this string is added at the end of theproduces output as ARFF file type.- Overrides:
generateFinishedin classMexicanHat- Returns:
- string contains info about the generated rules
- Throws:
java.lang.Exception- if the generating of the documentaion fails
-
getRevision
public java.lang.String getRevision()
Returns the revision string.- Specified by:
getRevisionin interfaceRevisionHandler- Overrides:
getRevisionin classMexicanHat- Returns:
- the revision
-
main
public static void main(java.lang.String[] args)
Main method for testing this class.- Parameters:
args- should contain arguments for the data producer:
-
-