Package weka.classifiers
Class GroupedCrossValidationFoldGeneratorUsingNumericClassValues
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- weka.classifiers.AbstractSplitGenerator
-
- weka.classifiers.GroupedCrossValidationFoldGeneratorUsingNumericClassValues
-
- All Implemented Interfaces:
adams.core.Destroyable
,adams.core.GlobalInfoSupporter
,adams.core.logging.LoggingLevelHandler
,adams.core.logging.LoggingSupporter
,adams.core.option.OptionHandler
,adams.core.Randomizable
,adams.core.SizeOfHandler
,adams.data.splitgenerator.CrossValidationFoldGenerator<weka.core.Instances,WekaTrainTestSetContainer>
,adams.data.splitgenerator.SplitGenerator<weka.core.Instances,WekaTrainTestSetContainer>
,adams.data.splitgenerator.StratifiableSplitGenerator<weka.core.Instances,WekaTrainTestSetContainer>
,InstancesViewSupporter
,Serializable
,Iterator<WekaTrainTestSetContainer>
,CrossValidationFoldGenerator
,SplitGenerator
public class GroupedCrossValidationFoldGeneratorUsingNumericClassValues extends AbstractSplitGenerator implements CrossValidationFoldGenerator
Helper class for generating cross-validation folds.
Uses the string representation of the numeric class values as grouping.
The template for the relation name accepts the following placeholders:- Author:
- FracPete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected int
m_ActualNumFolds
the actual number of folds.protected List<adams.data.binning.Binnable<adams.data.binning.BinnableGroup<weka.core.Instance>>>
m_BinnableGroups
the collapsed data.protected int
m_CurrentFold
the current fold.protected List<adams.data.splitgenerator.generic.crossvalidation.FoldPair<adams.data.binning.Binnable<adams.data.binning.BinnableGroup<weka.core.Instance>>>>
m_FoldPairs
the temporary pairs.protected adams.data.splitgenerator.generic.crossvalidation.CrossValidationGenerator
m_Generator
the underlying scheme for generating the folds.protected int
m_NumFolds
the number of folds.protected boolean
m_Randomize
whether to randomize the data.protected String
m_RelationName
the template for the relation name.-
Fields inherited from class weka.classifiers.AbstractSplitGenerator
m_Data, m_Initialized, m_OriginalIndices, m_Seed, m_UseViews
-
-
Constructor Summary
Constructors Constructor Description GroupedCrossValidationFoldGeneratorUsingNumericClassValues()
Initializes the generator.GroupedCrossValidationFoldGeneratorUsingNumericClassValues(weka.core.Instances data, int numFolds, long seed, boolean randomize)
Initializes the generator.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected boolean
canRandomize()
Returns whether randomization is enabled.protected boolean
checkNext()
Returns true if the iteration has more elements.protected WekaTrainTestSetContainer
createNext()
Returns the next element in the iteration.int[]
crossValidationIndices()
Returns the cross-validation indices.void
defineOptions()
Adds options to the internal list of options.protected void
doInitializeIterator()
Initializes the iterator, randomizes the data if required.int
getActualNumFolds()
Returns the actual number of folds used (eg when using LOO).int
getNumFolds()
Returns the number of folds.boolean
getRandomize()
Returns whether to randomize the data.String
getRelationName()
Returns the relation name template.boolean
getStratify()
Returns whether to stratify the data (in case of nominal class).String
globalInfo()
Returns a string describing the object.String
numFoldsTipText()
Returns the tip text for this property.String
randomizeTipText()
Returns the tip text for this property.String
relationNameTipText()
Returns the tip text for this property.protected void
reset()
Resets the generator.void
setData(weka.core.Instances value)
Sets the original data.void
setNumFolds(int value)
Sets the number of folds to use.void
setRandomize(boolean value)
Sets whether to randomize the data.void
setRelationName(String value)
Sets the template for the relation name.void
setStratify(boolean value)
Sets whether to stratify the data (nominal class).String
toString()
Returns a short description of the generator.-
Methods inherited from class weka.classifiers.AbstractSplitGenerator
getData, getSeed, getUseViews, hasNext, initialize, initializeIterator, next, randomize, remove, seedTipText, setSeed, setUseViews, useViewsTipText
-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, loggingLevelTipText, newOptionManager, setLoggingLevel, toCommandLine
-
Methods inherited from class adams.core.logging.LoggingObject
configureLogger, getLogger, getLoggingLevel, initializeLogging, isLoggingEnabled, sizeOf
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface adams.data.weka.InstancesViewSupporter
getUseViews, setUseViews
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
Methods inherited from interface weka.classifiers.SplitGenerator
getData, hasNext, initializeIterator, next, remove
-
-
-
-
Field Detail
-
m_NumFolds
protected int m_NumFolds
the number of folds.
-
m_ActualNumFolds
protected int m_ActualNumFolds
the actual number of folds.
-
m_CurrentFold
protected int m_CurrentFold
the current fold.
-
m_RelationName
protected String m_RelationName
the template for the relation name.
-
m_Randomize
protected boolean m_Randomize
whether to randomize the data.
-
m_Generator
protected transient adams.data.splitgenerator.generic.crossvalidation.CrossValidationGenerator m_Generator
the underlying scheme for generating the folds.
-
m_BinnableGroups
protected transient List<adams.data.binning.Binnable<adams.data.binning.BinnableGroup<weka.core.Instance>>> m_BinnableGroups
the collapsed data.
-
m_FoldPairs
protected transient List<adams.data.splitgenerator.generic.crossvalidation.FoldPair<adams.data.binning.Binnable<adams.data.binning.BinnableGroup<weka.core.Instance>>>> m_FoldPairs
the temporary pairs.
-
-
Constructor Detail
-
GroupedCrossValidationFoldGeneratorUsingNumericClassValues
public GroupedCrossValidationFoldGeneratorUsingNumericClassValues()
Initializes the generator.
-
GroupedCrossValidationFoldGeneratorUsingNumericClassValues
public GroupedCrossValidationFoldGeneratorUsingNumericClassValues(weka.core.Instances data, int numFolds, long seed, boolean randomize)
Initializes the generator.- Parameters:
data
- the full datasetnumFolds
- the number of folds, leave-one-out if less than 2seed
- the seed for randomization
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceadams.core.GlobalInfoSupporter
- Specified by:
globalInfo
in classadams.core.option.AbstractOptionHandler
- Returns:
- a description suitable for displaying in the gui
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceadams.core.option.OptionHandler
- Overrides:
defineOptions
in classAbstractSplitGenerator
-
reset
protected void reset()
Resets the generator.- Overrides:
reset
in classAbstractSplitGenerator
-
setData
public void setData(weka.core.Instances value)
Sets the original data.- Specified by:
setData
in interfaceadams.data.splitgenerator.SplitGenerator<weka.core.Instances,WekaTrainTestSetContainer>
- Specified by:
setData
in interfaceSplitGenerator
- Overrides:
setData
in classAbstractSplitGenerator
- Parameters:
value
- the data
-
setNumFolds
public void setNumFolds(int value)
Sets the number of folds to use.- Specified by:
setNumFolds
in interfaceadams.data.splitgenerator.CrossValidationFoldGenerator<weka.core.Instances,WekaTrainTestSetContainer>
- Specified by:
setNumFolds
in interfaceCrossValidationFoldGenerator
- Parameters:
value
- the number of folds, less than 2 for LOO
-
getNumFolds
public int getNumFolds()
Returns the number of folds.- Specified by:
getNumFolds
in interfaceadams.data.splitgenerator.CrossValidationFoldGenerator<weka.core.Instances,WekaTrainTestSetContainer>
- Specified by:
getNumFolds
in interfaceCrossValidationFoldGenerator
- Returns:
- the number of folds
-
numFoldsTipText
public String numFoldsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
getActualNumFolds
public int getActualNumFolds()
Returns the actual number of folds used (eg when using LOO).- Specified by:
getActualNumFolds
in interfaceadams.data.splitgenerator.CrossValidationFoldGenerator<weka.core.Instances,WekaTrainTestSetContainer>
- Specified by:
getActualNumFolds
in interfaceCrossValidationFoldGenerator
- Returns:
- the actual number of folds, -1 if not yet calculated
- See Also:
AbstractSplitGenerator.initializeIterator()
-
setRandomize
public void setRandomize(boolean value)
Sets whether to randomize the data.- Specified by:
setRandomize
in interfaceadams.data.splitgenerator.CrossValidationFoldGenerator<weka.core.Instances,WekaTrainTestSetContainer>
- Specified by:
setRandomize
in interfaceCrossValidationFoldGenerator
- Parameters:
value
- true if to randomize the data
-
getRandomize
public boolean getRandomize()
Returns whether to randomize the data.- Specified by:
getRandomize
in interfaceadams.data.splitgenerator.CrossValidationFoldGenerator<weka.core.Instances,WekaTrainTestSetContainer>
- Specified by:
getRandomize
in interfaceCrossValidationFoldGenerator
- Returns:
- true if to randomize the data
-
randomizeTipText
public String randomizeTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setRelationName
public void setRelationName(String value)
Sets the template for the relation name.- Specified by:
setRelationName
in interfaceCrossValidationFoldGenerator
- Parameters:
value
- the template
-
getRelationName
public String getRelationName()
Returns the relation name template.- Specified by:
getRelationName
in interfaceCrossValidationFoldGenerator
- Returns:
- the template
-
relationNameTipText
public String relationNameTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setStratify
public void setStratify(boolean value)
Sets whether to stratify the data (nominal class).- Specified by:
setStratify
in interfaceCrossValidationFoldGenerator
- Specified by:
setStratify
in interfaceadams.data.splitgenerator.StratifiableSplitGenerator<weka.core.Instances,WekaTrainTestSetContainer>
- Parameters:
value
- ignored
-
getStratify
public boolean getStratify()
Returns whether to stratify the data (in case of nominal class).- Specified by:
getStratify
in interfaceCrossValidationFoldGenerator
- Specified by:
getStratify
in interfaceadams.data.splitgenerator.StratifiableSplitGenerator<weka.core.Instances,WekaTrainTestSetContainer>
- Returns:
- always false
-
canRandomize
protected boolean canRandomize()
Returns whether randomization is enabled.- Specified by:
canRandomize
in classAbstractSplitGenerator
- Returns:
- true if to randomize
-
checkNext
protected boolean checkNext()
Returns true if the iteration has more elements. (In other words, returns true if next would return an element rather than throwing an exception.)- Specified by:
checkNext
in classAbstractSplitGenerator
- Returns:
- true if the iterator has more elements.
-
doInitializeIterator
protected void doInitializeIterator()
Initializes the iterator, randomizes the data if required.- Specified by:
doInitializeIterator
in classAbstractSplitGenerator
- See Also:
AbstractSplitGenerator.canRandomize()
-
createNext
protected WekaTrainTestSetContainer createNext()
Returns the next element in the iteration.- Specified by:
createNext
in classAbstractSplitGenerator
- Returns:
- the next element in the iteration.
- Throws:
NoSuchElementException
- iteration has no more elements.
-
crossValidationIndices
public int[] crossValidationIndices()
Returns the cross-validation indices.- Specified by:
crossValidationIndices
in interfaceadams.data.splitgenerator.CrossValidationFoldGenerator<weka.core.Instances,WekaTrainTestSetContainer>
- Specified by:
crossValidationIndices
in interfaceCrossValidationFoldGenerator
- Returns:
- the indices
-
toString
public String toString()
Returns a short description of the generator.- Specified by:
toString
in interfaceadams.data.splitgenerator.SplitGenerator<weka.core.Instances,WekaTrainTestSetContainer>
- Specified by:
toString
in interfaceSplitGenerator
- Overrides:
toString
in classAbstractSplitGenerator
- Returns:
- a short description
-
-