Package weka.classifiers
Class LeaveOneOutByValueGenerator
- java.lang.Object
-
- adams.core.logging.LoggingObject
-
- adams.core.logging.CustomLoggingLevelObject
-
- adams.core.option.AbstractOptionHandler
-
- weka.classifiers.AbstractSplitGenerator
-
- weka.classifiers.LeaveOneOutByValueGenerator
-
- 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.SplitGenerator<weka.core.Instances,WekaTrainTestSetContainer>,InstancesViewSupporter,Serializable,Iterator<WekaTrainTestSetContainer>,SplitGenerator
public class LeaveOneOutByValueGenerator extends AbstractSplitGenerator
Generates train/test split pairs using the unique values from the specified attribute. All values apart from one will be part of the training data and the remainder the test set. This is repeated for each unique value.
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 intm_CurrentPairthe current train/test pair to generate.protected WekaAttributeIndexm_Indexthe index to get the unique values from.protected booleanm_Randomizewhether to randomize the data.protected Stringm_RelationNamethe template for the relation name.protected List<String>m_UniqueValuesthe unique values.static StringPLACEHOLDER_CURRENTVALUEthe placeholder for the current value in the test set.static StringPLACEHOLDER_ORIGINALthe placeholder for the (original) relation name.static StringPLACEHOLDER_TYPEthe placeholder for "train" or "test" type.-
Fields inherited from class weka.classifiers.AbstractSplitGenerator
m_Data, m_Initialized, m_OriginalIndices, m_OriginalIndicesPerFold, m_Seed, m_UseViews
-
-
Constructor Summary
Constructors Constructor Description LeaveOneOutByValueGenerator()Initializes the generator.LeaveOneOutByValueGenerator(weka.core.Instances data, long seed, boolean randomize, WekaAttributeIndex index)Initializes the generator.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected booleancanRandomize()Returns whether randomization is enabled.protected booleancheckNext()Returns true if the iteration has more elements.protected WekaTrainTestSetContainercreateNext()Returns the next element in the iteration.protected StringcreateRelationName(String relation, String template, String current, boolean train)Generates a relation name for the current value.voiddefineOptions()Adds options to the internal list of options.protected voiddoInitializeIterator()Initializes the iterator, randomizes the data if required.WekaAttributeIndexgetIndex()Returns the attribute index to use for grouping.booleangetRandomize()Returns whether to randomize the data.StringgetRelationName()Returns the relation name template.StringglobalInfo()Returns a string describing the object.StringindexTipText()Returns the tip text for this property.StringrandomizeTipText()Returns the tip text for this property.static StringrelationNameTipText()Returns the tiptext for the relation name template.protected voidreset()Resets the generator.voidsetIndex(WekaAttributeIndex value)Sets the attribute index to use for grouping.voidsetRandomize(boolean value)Sets whether to randomize the data.voidsetRelationName(String value)Sets the template for the relation name.StringtoString()Returns a short description of the generator.-
Methods inherited from class weka.classifiers.AbstractSplitGenerator
getData, getSeed, getUseViews, hasNext, initialize, initializeIterator, next, randomize, remove, 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 java.util.Iterator
forEachRemaining
-
-
-
-
Field Detail
-
PLACEHOLDER_ORIGINAL
public static final String PLACEHOLDER_ORIGINAL
the placeholder for the (original) relation name.- See Also:
- Constant Field Values
-
PLACEHOLDER_TYPE
public static final String PLACEHOLDER_TYPE
the placeholder for "train" or "test" type.- See Also:
- Constant Field Values
-
PLACEHOLDER_CURRENTVALUE
public static final String PLACEHOLDER_CURRENTVALUE
the placeholder for the current value in the test set.- See Also:
- Constant Field Values
-
m_RelationName
protected String m_RelationName
the template for the relation name.
-
m_Randomize
protected boolean m_Randomize
whether to randomize the data.
-
m_Index
protected WekaAttributeIndex m_Index
the index to get the unique values from.
-
m_CurrentPair
protected transient int m_CurrentPair
the current train/test pair to generate.
-
-
Constructor Detail
-
LeaveOneOutByValueGenerator
public LeaveOneOutByValueGenerator()
Initializes the generator.
-
LeaveOneOutByValueGenerator
public LeaveOneOutByValueGenerator(weka.core.Instances data, long seed, boolean randomize, WekaAttributeIndex index)Initializes the generator.- Parameters:
data- the full datasetseed- the seed for randomizationrandomize- whether to randomize the dataindex- the attribute index
-
-
Method Detail
-
globalInfo
public String globalInfo()
Returns a string describing the object.- Specified by:
globalInfoin interfaceadams.core.GlobalInfoSupporter- Specified by:
globalInfoin 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:
defineOptionsin interfaceadams.core.option.OptionHandler- Overrides:
defineOptionsin classAbstractSplitGenerator
-
reset
protected void reset()
Resets the generator.- Overrides:
resetin classAbstractSplitGenerator
-
setIndex
public void setIndex(WekaAttributeIndex value)
Sets the attribute index to use for grouping.- Parameters:
value- the index
-
getIndex
public WekaAttributeIndex getIndex()
Returns the attribute index to use for grouping.- Returns:
- the index
-
indexTipText
public String indexTipText()
Returns the tip text for this property.- Returns:
- tip text for this property suitable for displaying in the GUI or for listing the options.
-
setRandomize
public void setRandomize(boolean value)
Sets whether to randomize the data.- Parameters:
value- true if to randomize the data
-
getRandomize
public boolean getRandomize()
Returns whether to randomize the data.- 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.- Parameters:
value- the template
-
getRelationName
public String getRelationName()
Returns the relation name template.- Returns:
- the template
-
relationNameTipText
public static String relationNameTipText()
Returns the tiptext for the relation name template.- Returns:
- the tiptext
-
canRandomize
protected boolean canRandomize()
Returns whether randomization is enabled.- Specified by:
canRandomizein 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:
checkNextin classAbstractSplitGenerator- Returns:
- true if the iterator has more elements.
-
doInitializeIterator
protected void doInitializeIterator()
Initializes the iterator, randomizes the data if required.- Specified by:
doInitializeIteratorin classAbstractSplitGenerator- See Also:
AbstractSplitGenerator.canRandomize()
-
createRelationName
protected String createRelationName(String relation, String template, String current, boolean train)
Generates a relation name for the current value.- Parameters:
relation- the original relation nametemplate- the template for the relation namecurrent- the current valuetrain- whether train or test set- Returns:
- the relation name
-
createNext
protected WekaTrainTestSetContainer createNext()
Returns the next element in the iteration.- Specified by:
createNextin classAbstractSplitGenerator- Returns:
- the next element in the iteration.
- Throws:
NoSuchElementException- iteration has no more elements.
-
toString
public String toString()
Returns a short description of the generator.- Specified by:
toStringin interfaceadams.data.splitgenerator.SplitGenerator<weka.core.Instances,WekaTrainTestSetContainer>- Specified by:
toStringin interfaceSplitGenerator- Overrides:
toStringin classAbstractSplitGenerator- Returns:
- a short description
-
-