Package adams.ml.evaluation
Class DefaultRandomSplitGenerator
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- adams.ml.evaluation.AbstractSplitGenerator
-
- adams.ml.evaluation.DefaultRandomSplitGenerator
-
- All Implemented Interfaces:
Destroyable
,GlobalInfoSupporter
,LoggingLevelHandler
,LoggingSupporter
,OptionHandler
,Randomizable
,SizeOfHandler
,RandomSplitGenerator<Dataset,TrainTestSetContainer>
,SplitGenerator<Dataset,TrainTestSetContainer>
,Serializable
,Iterator<TrainTestSetContainer>
public class DefaultRandomSplitGenerator extends AbstractSplitGenerator implements RandomSplitGenerator<Dataset,TrainTestSetContainer>
Generates random splits of datasets.- Author:
- fracpete (fracpete at waikato dot ac dot nz)
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected boolean
m_Generated
whether the split was generated.protected RandomSplitGenerator
m_Generator
the underlying scheme for generating the split.protected double
m_Percentage
the percentage.protected boolean
m_PreserveOrder
whether to preserve the order.-
Fields inherited from class adams.ml.evaluation.AbstractSplitGenerator
m_Data, m_Initialized, m_OriginalIndices, m_Seed, m_UseViews
-
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 Constructor Description DefaultRandomSplitGenerator()
Initializes the generator.DefaultRandomSplitGenerator(Dataset data, double percentage)
Initializes the generator.DefaultRandomSplitGenerator(Dataset data, long seed, double percentage)
Initializes the generator.DefaultRandomSplitGenerator(Dataset data, long seed, double percentage, boolean preserveOrder)
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 TrainTestSetContainer
createNext()
Creates the next result.void
defineOptions()
Adds options to the internal list of options.protected void
doInitializeIterator()
Initializes the iterator, randomizes the data if required.double
getPercentage()
Returns the split percentage.boolean
getPreserveOrder()
Returns whether to preserve the order.String
globalInfo()
Returns a string describing the object.String
percentageTipText()
Returns the tip text for this property.String
preserveOrderTipText()
Returns the tip text for this property.void
setPercentage(double value)
Sets the split percentage.void
setPreserveOrder(boolean value)
Sets whether to preserve the order.String
toString()
Returns a short description of the generator.-
Methods inherited from class adams.ml.evaluation.AbstractSplitGenerator
getData, getSeed, getUseViews, hasNext, initialize, initializeIterator, next, randomize, remove, reset, seedTipText, setData, 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.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
-
Methods inherited from interface adams.core.Randomizable
getSeed, seedTipText, setSeed
-
Methods inherited from interface adams.data.splitgenerator.SplitGenerator
getData, hasNext, initializeIterator, next, remove, setData
-
-
-
-
Field Detail
-
m_Percentage
protected double m_Percentage
the percentage.
-
m_PreserveOrder
protected boolean m_PreserveOrder
whether to preserve the order.
-
m_Generated
protected boolean m_Generated
whether the split was generated.
-
m_Generator
protected RandomSplitGenerator m_Generator
the underlying scheme for generating the split.
-
-
Constructor Detail
-
DefaultRandomSplitGenerator
public DefaultRandomSplitGenerator()
Initializes the generator.
-
DefaultRandomSplitGenerator
public DefaultRandomSplitGenerator(Dataset data, long seed, double percentage)
Initializes the generator. Does not preserve the order.- Parameters:
data
- the dataset to splitseed
- the seed value to use for randomizationpercentage
- the percentage of the training set (0-1)
-
DefaultRandomSplitGenerator
public DefaultRandomSplitGenerator(Dataset data, double percentage)
Initializes the generator. Preserves the order.- Parameters:
data
- the dataset to splitpercentage
- the percentage of the training set (0-1)
-
DefaultRandomSplitGenerator
public DefaultRandomSplitGenerator(Dataset data, long seed, double percentage, boolean preserveOrder)
Initializes the generator. Does not preserve the order.- Parameters:
data
- the dataset to splitseed
- the seed value to use for randomizationpercentage
- the percentage of the training set (0-1)preserveOrder
- whether to preserve the order
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfo
in interfaceGlobalInfoSupporter
- Specified by:
globalInfo
in classAbstractOptionHandler
- 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 interfaceOptionHandler
- Overrides:
defineOptions
in classAbstractSplitGenerator
-
setPercentage
public void setPercentage(double value)
Sets the split percentage.- Specified by:
setPercentage
in interfaceRandomSplitGenerator<Dataset,TrainTestSetContainer>
- Parameters:
value
- the percentage (0-1)
-
getPercentage
public double getPercentage()
Returns the split percentage.- Specified by:
getPercentage
in interfaceRandomSplitGenerator<Dataset,TrainTestSetContainer>
- Returns:
- the percentage (0-1)
-
percentageTipText
public String percentageTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setPreserveOrder
public void setPreserveOrder(boolean value)
Sets whether to preserve the order.- Specified by:
setPreserveOrder
in interfaceRandomSplitGenerator<Dataset,TrainTestSetContainer>
- Parameters:
value
- true if to preserve order
-
getPreserveOrder
public boolean getPreserveOrder()
Returns whether to preserve the order.- Specified by:
getPreserveOrder
in interfaceRandomSplitGenerator<Dataset,TrainTestSetContainer>
- Returns:
- true if to preserve order
-
preserveOrderTipText
public String preserveOrderTipText()
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 boolean canRandomize()
Returns whether randomization is enabled.- Specified by:
canRandomize
in classAbstractSplitGenerator
- Returns:
- true if to randomize
-
doInitializeIterator
protected void doInitializeIterator()
Initializes the iterator, randomizes the data if required.- Specified by:
doInitializeIterator
in classAbstractSplitGenerator
- See Also:
canRandomize()
-
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.
-
createNext
protected TrainTestSetContainer createNext()
Creates the next result.- Specified by:
createNext
in classAbstractSplitGenerator
- Returns:
- the next result
-
toString
public String toString()
Returns a short description of the generator.- Specified by:
toString
in interfaceSplitGenerator<Dataset,TrainTestSetContainer>
- Overrides:
toString
in classAbstractSplitGenerator
- Returns:
- a short description
-
-