Package adams.ml.evaluation
Class AbstractSplitGenerator
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.ml.evaluation.AbstractSplitGenerator
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,Randomizable
,SizeOfHandler
,SplitGenerator<Dataset,TrainTestSetContainer>
,Serializable
,Iterator<TrainTestSetContainer>
- Direct Known Subclasses:
DefaultCrossValidationFoldGenerator
,DefaultRandomSplitGenerator
public abstract class AbstractSplitGenerator extends AbstractOptionHandler implements SplitGenerator<Dataset,TrainTestSetContainer>
Ancestor for helper classes that generates dataset splits.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected Dataset
m_Data
the original dataset.protected boolean
m_Initialized
whether the iterator has been initialized.protected gnu.trove.list.TIntList
m_OriginalIndices
the original indicies.protected long
m_Seed
the seed value.protected boolean
m_UseViews
whether to use views.-
Fields inherited from class adams.core.option.AbstractOptionHandler
m_OptionManager
-
Fields inherited from class adams.core.logging.LoggingObject
m_Logger, m_LoggingIsEnabled, m_LoggingLevel
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
AbstractSplitGenerator()
Initializes the generator.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected abstract boolean
canRandomize()
Returns whether randomization is enabled.protected abstract boolean
checkNext()
Returns true if the iteration has more elements.protected abstract TrainTestSetContainer
createNext()
Creates the next result.void
defineOptions()
Adds options to the internal list of options.protected abstract void
doInitializeIterator()
Initializes the iterator, randomizes the data if required.Dataset
getData()
Returns the original data.long
getSeed()
Returns the seed value.boolean
getUseViews()
Returns whether to use views.boolean
hasNext()
Returns true if the iteration has more elements.protected void
initialize()
Initializes the members.void
initializeIterator()
Initializes the iterator, randomizes the data if required.TrainTestSetContainer
next()
Returns the next element in the iteration.protected void
randomize(gnu.trove.list.TIntList indices, Random random)
Randomizes the indices using the given random number generator.void
remove()
Unsupported.protected void
reset()
Resets the generator.String
seedTipText()
Returns the tip text for this property.void
setData(Dataset value)
Sets the original data.void
setSeed(long value)
Sets the seed value.void
setUseViews(boolean value)
Sets whether to uses views only.String
toString()
Returns a short description of the generator.String
useViewsTipText()
Returns the tip text for this property.-
Methods inherited from class adams.core.option.AbstractOptionHandler
cleanUpOptions, destroy, finishInit, getDefaultLoggingLevel, getOptionManager, globalInfo, 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.core.Destroyable
destroy
-
Methods inherited from interface java.util.Iterator
forEachRemaining
-
Methods inherited from interface adams.core.logging.LoggingLevelHandler
getLoggingLevel
-
Methods inherited from interface adams.core.option.OptionHandler
cleanUpOptions, getOptionManager, toCommandLine
-
-
-
-
Field Detail
-
m_Seed
protected long m_Seed
the seed value.
-
m_UseViews
protected boolean m_UseViews
whether to use views.
-
m_Data
protected Dataset m_Data
the original dataset.
-
m_Initialized
protected boolean m_Initialized
whether the iterator has been initialized.
-
m_OriginalIndices
protected gnu.trove.list.TIntList m_OriginalIndices
the original indicies.
-
-
Method Detail
-
defineOptions
public void defineOptions()
Adds options to the internal list of options.- Specified by:
defineOptions
in interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractOptionHandler
-
initialize
protected void initialize()
Initializes the members.- Overrides:
initialize
in classAbstractOptionHandler
-
reset
protected void reset()
Resets the generator.- Overrides:
reset
in classAbstractOptionHandler
-
setData
public void setData(Dataset value)
Sets the original data.- Specified by:
setData
in interfaceSplitGenerator<Dataset,TrainTestSetContainer>
- Parameters:
value
- the data
-
getData
public Dataset getData()
Returns the original data.- Specified by:
getData
in interfaceSplitGenerator<Dataset,TrainTestSetContainer>
- Returns:
- the data
-
setSeed
public void setSeed(long value)
Sets the seed value.- Specified by:
setSeed
in interfaceRandomizable
- Parameters:
value
- the seed
-
getSeed
public long getSeed()
Returns the seed value.- Specified by:
getSeed
in interfaceRandomizable
- Returns:
- the seed
-
seedTipText
public String seedTipText()
Returns the tip text for this property.- Specified by:
seedTipText
in interfaceRandomizable
- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setUseViews
public void setUseViews(boolean value)
Sets whether to uses views only.- Parameters:
value
- true if to uses views
-
getUseViews
public boolean getUseViews()
Returns whether to use views.- Returns:
- true if to uses views
-
useViewsTipText
public String useViewsTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
canRandomize
protected abstract boolean canRandomize()
Returns whether randomization is enabled.- Returns:
- true if to randomize
-
checkNext
protected abstract 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.)- Returns:
- true if the iterator has more elements.
-
hasNext
public boolean hasNext()
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:
hasNext
in interfaceIterator<TrainTestSetContainer>
- Specified by:
hasNext
in interfaceSplitGenerator<Dataset,TrainTestSetContainer>
- Returns:
- true if the iterator has more elements.
-
randomize
protected void randomize(gnu.trove.list.TIntList indices, Random random)
Randomizes the indices using the given random number generator.- Parameters:
indices
- the indices to randomize inplacerandom
- the random number generator to use
-
doInitializeIterator
protected abstract void doInitializeIterator()
Initializes the iterator, randomizes the data if required.- See Also:
canRandomize()
-
initializeIterator
public void initializeIterator()
Initializes the iterator, randomizes the data if required.- Specified by:
initializeIterator
in interfaceSplitGenerator<Dataset,TrainTestSetContainer>
- See Also:
canRandomize()
-
createNext
protected abstract TrainTestSetContainer createNext()
Creates the next result.- Returns:
- the next result
-
next
public TrainTestSetContainer next()
Returns the next element in the iteration.- Specified by:
next
in interfaceIterator<TrainTestSetContainer>
- Specified by:
next
in interfaceSplitGenerator<Dataset,TrainTestSetContainer>
- Returns:
- the next element in the iteration.
- Throws:
NoSuchElementException
- iteration has no more elements.
-
remove
public void remove()
Unsupported.- Specified by:
remove
in interfaceIterator<TrainTestSetContainer>
- Specified by:
remove
in interfaceSplitGenerator<Dataset,TrainTestSetContainer>
-
toString
public String toString()
Returns a short description of the generator.- Specified by:
toString
in interfaceSplitGenerator<Dataset,TrainTestSetContainer>
- Overrides:
toString
in classAbstractOptionHandler
- Returns:
- a short description
-
-