Package weka.classifiers.functions
Class GeneticAlgorithm
- java.lang.Object
-
- weka.classifiers.AbstractClassifier
-
- weka.classifiers.functions.GeneticAlgorithm
-
- All Implemented Interfaces:
Serializable
,Cloneable
,weka.classifiers.Classifier
,weka.core.BatchPredictor
,weka.core.CapabilitiesHandler
,weka.core.CapabilitiesIgnorer
,weka.core.CommandlineRunnable
,weka.core.OptionHandler
,weka.core.RevisionHandler
public class GeneticAlgorithm extends weka.classifiers.AbstractClassifier
Applies the specified genetic algorithm to the training data and uses the best setup for the final model. Valid options are:-algorithm <classname + options> The genetic algorithm. (default: adams.genetic.Hermione)
-output-debug-info If set, classifier is run in debug mode and may output additional info to the console
-do-not-check-capabilities If set, classifier capabilities are not checked before classifier is built (use with caution).
- Version:
- $Revision$
- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected AbstractClassifierBasedGeneticAlgorithm
m_Algorithm
the genetic algorithm.protected weka.classifiers.Classifier
m_Model
the final model.
-
Constructor Summary
Constructors Constructor Description GeneticAlgorithm()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description String
algorithmTipText()
Returns the tip text for this property.void
buildClassifier(weka.core.Instances data)
Generates a classifier.double
classifyInstance(weka.core.Instance instance)
Classifies the given test instance.double[]
distributionForInstance(weka.core.Instance instance)
Predicts the class memberships for a given instance.AbstractClassifierBasedGeneticAlgorithm
getAlgorithm()
Returns the seed value for the random values.weka.core.Capabilities
getCapabilities()
Returns the Capabilities of this classifier.String[]
getOptions()
returns the options of the current setupString
getRevision()
Returns the revision string.String
globalInfo()
Returns a string describing classifierEnumeration
listOptions()
Gets an enumeration describing the available options.static void
main(String[] args)
Main method for running this class.void
setAlgorithm(AbstractClassifierBasedGeneticAlgorithm value)
Sets the genetic algorithm to use.void
setOptions(String[] options)
Parses the options for this object.String
toString()
Returns a string representation of the built model.-
Methods inherited from class weka.classifiers.AbstractClassifier
batchSizeTipText, debugTipText, distributionsForInstances, doNotCheckCapabilitiesTipText, forName, getBatchSize, getDebug, getDoNotCheckCapabilities, getNumDecimalPlaces, implementsMoreEfficientBatchPrediction, makeCopies, makeCopy, numDecimalPlacesTipText, postExecution, preExecution, run, runClassifier, setBatchSize, setDebug, setDoNotCheckCapabilities, setNumDecimalPlaces
-
-
-
-
Field Detail
-
m_Algorithm
protected AbstractClassifierBasedGeneticAlgorithm m_Algorithm
the genetic algorithm.
-
m_Model
protected weka.classifiers.Classifier m_Model
the final model.
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing classifier- 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 interfaceweka.core.OptionHandler
- Overrides:
listOptions
in classweka.classifiers.AbstractClassifier
- Returns:
- an enumeration of all the available options.
-
getOptions
public String[] getOptions()
returns the options of the current setup- Specified by:
getOptions
in interfaceweka.core.OptionHandler
- Overrides:
getOptions
in classweka.classifiers.AbstractClassifier
- Returns:
- the current options
-
setOptions
public void setOptions(String[] options) throws Exception
Parses the options for this object.- Specified by:
setOptions
in interfaceweka.core.OptionHandler
- Overrides:
setOptions
in classweka.classifiers.AbstractClassifier
- Parameters:
options
- the options to use- Throws:
Exception
- if setting of options fails
-
setAlgorithm
public void setAlgorithm(AbstractClassifierBasedGeneticAlgorithm value)
Sets the genetic algorithm to use.- Parameters:
value
- the algorithm
-
getAlgorithm
public AbstractClassifierBasedGeneticAlgorithm getAlgorithm()
Returns the seed value for the random values.- Returns:
- the seed
-
algorithmTipText
public String algorithmTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the explorer/experimenter gui
-
getCapabilities
public weka.core.Capabilities getCapabilities()
Returns the Capabilities of this classifier. Maximally permissive capabilities are allowed by default. Derived classifiers should override this method and first disable all capabilities and then enable just those capabilities that make sense for the scheme.- Specified by:
getCapabilities
in interfaceweka.core.CapabilitiesHandler
- Specified by:
getCapabilities
in interfaceweka.classifiers.Classifier
- Overrides:
getCapabilities
in classweka.classifiers.AbstractClassifier
- Returns:
- the capabilities of this object
- See Also:
Capabilities
-
buildClassifier
public void buildClassifier(weka.core.Instances data) throws Exception
Generates a classifier.- Parameters:
data
- set of instances serving as training data- Throws:
Exception
- if the classifier has not been generated successfully
-
classifyInstance
public double classifyInstance(weka.core.Instance instance) throws Exception
Classifies the given test instance. The instance has to belong to a dataset when it's being classified.- Specified by:
classifyInstance
in interfaceweka.classifiers.Classifier
- Overrides:
classifyInstance
in classweka.classifiers.AbstractClassifier
- Parameters:
instance
- the instance to be classified- Returns:
- the predicted most likely class for the instance or Instance.missingValue() if no prediction is made
- Throws:
Exception
- if an error occurred during the prediction
-
distributionForInstance
public double[] distributionForInstance(weka.core.Instance instance) throws Exception
Predicts the class memberships for a given instance. If an instance is unclassified, the returned array elements must be all zero. If the class is numeric, the array must consist of only one element, which contains the predicted value.- Specified by:
distributionForInstance
in interfaceweka.classifiers.Classifier
- Overrides:
distributionForInstance
in classweka.classifiers.AbstractClassifier
- Parameters:
instance
- the instance to be classified- Returns:
- an array containing the estimated membership probabilities of the test instance in each class or the numeric prediction
- Throws:
Exception
- if distribution could not be computed successfully
-
getRevision
public String getRevision()
Returns the revision string.- Specified by:
getRevision
in interfaceweka.core.RevisionHandler
- Overrides:
getRevision
in classweka.classifiers.AbstractClassifier
- Returns:
- the revision
-
toString
public String toString()
Returns a string representation of the built model.
-
main
public static void main(String[] args)
Main method for running this class.- Parameters:
args
- the commandline parameters
-
-