Class MetaMultilabelGenerator
- java.lang.Object
-
- moa.AbstractMOAObject
-
- moa.options.AbstractOptionHandler
-
- moa.streams.generators.multilabel.MetaMultilabelGenerator
-
- All Implemented Interfaces:
Configurable
,Serializable
,CapabilitiesHandler
,MOAObject
,OptionHandler
,ExampleStream<Example<Instance>>
,InstanceStream
,MultiTargetInstanceStream
public class MetaMultilabelGenerator extends AbstractOptionHandler implements MultiTargetInstanceStream
Stream generator for multilabel data.- Version:
- $Revision: 7 $
- Author:
- Jesse Read ((jesse@tsc.uc3m.es))
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description ClassOption
binaryGeneratorOption
protected double[][]
Conditional
FloatOption
labelCardinalityOption
FloatOption
labelCardinalityRatioOption
FloatOption
labelCardinalityVarOption
FloatOption
labelDependencyChangeRatioOption
protected int
m_A
protected InstanceStream
m_BinaryGenerator
protected int
m_L
protected Random
m_MetaRandom
protected MultilabelInstancesHeader
m_MultilabelInstancesHeader
protected HashSet[]
m_TopCombinations
IntOption
metaRandomSeedOption
protected Instances
multilabelStreamTemplate
IntOption
numLabelsOption
protected double[]
priors
protected double[]
priors_norm
IntOption
skewOption
-
Fields inherited from class moa.options.AbstractOptionHandler
config
-
-
Constructor Summary
Constructors Constructor Description MetaMultilabelGenerator()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description long
estimatedRemainingInstances()
Gets the estimated number of remaining instances in this streamprotected double[][]
generateConditional(double[] P, boolean[][] M)
GenerateConditional.protected MultilabelInstancesHeader
generateMultilabelHeader(Instances si)
GenerateMultilabelHeader.void
getDescription(StringBuilder sb, int indent)
Returns a string representation of this object.InstancesHeader
getHeader()
Gets the header of this stream.String
getPurposeString()
Dictionary with option texts and objectsboolean
hasMoreInstances()
Gets whether this stream has more instances to output.boolean
isRestartable()
Gets whether this stream can restart.static void
main(String[] args)
protected boolean[][]
modifyDependencyMatrix(boolean[][] M, double u, Random r)
ModifyDependencyMatrix.protected double[]
modifyPriorVector(double[] P, double u, Random r, boolean skew)
ModifyPriorVector.InstanceExample
nextInstance()
GenerateML.void
prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository)
This method describes the implementation of how to prepare this object for use.void
restart()
Restarts this stream.-
Methods inherited from class moa.options.AbstractOptionHandler
copy, getCLICreationString, getOptions, getPreparedClassOption, prepareClassOptions, prepareForUse, prepareForUse
-
Methods inherited from class moa.AbstractMOAObject
copy, measureByteSize, measureByteSize, toString
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface moa.capabilities.CapabilitiesHandler
getCapabilities
-
Methods inherited from interface moa.streams.ExampleStream
defineImmutableCapabilities
-
Methods inherited from interface moa.MOAObject
measureByteSize
-
-
-
-
Field Detail
-
binaryGeneratorOption
public ClassOption binaryGeneratorOption
-
metaRandomSeedOption
public IntOption metaRandomSeedOption
-
numLabelsOption
public IntOption numLabelsOption
-
skewOption
public IntOption skewOption
-
labelCardinalityOption
public FloatOption labelCardinalityOption
-
labelCardinalityVarOption
public FloatOption labelCardinalityVarOption
-
labelCardinalityRatioOption
public FloatOption labelCardinalityRatioOption
-
labelDependencyChangeRatioOption
public FloatOption labelDependencyChangeRatioOption
-
m_MultilabelInstancesHeader
protected MultilabelInstancesHeader m_MultilabelInstancesHeader
-
m_BinaryGenerator
protected InstanceStream m_BinaryGenerator
-
multilabelStreamTemplate
protected Instances multilabelStreamTemplate
-
m_MetaRandom
protected Random m_MetaRandom
-
m_L
protected int m_L
-
m_A
protected int m_A
-
priors
protected double[] priors
-
priors_norm
protected double[] priors_norm
-
Conditional
protected double[][] Conditional
-
m_TopCombinations
protected HashSet[] m_TopCombinations
-
-
Method Detail
-
prepareForUseImpl
public void prepareForUseImpl(TaskMonitor monitor, ObjectRepository repository)
Description copied from class:AbstractOptionHandler
This method describes the implementation of how to prepare this object for use. All classes that extends this class have to implementprepareForUseImpl
and notprepareForUse
sinceprepareForUse
callsprepareForUseImpl
.- Specified by:
prepareForUseImpl
in classAbstractOptionHandler
- Parameters:
monitor
- the TaskMonitor to userepository
- the ObjectRepository to use
-
restart
public void restart()
Description copied from interface:ExampleStream
Restarts this stream. It must be similar to starting a new stream from scratch.- Specified by:
restart
in interfaceExampleStream<Example<Instance>>
-
generateMultilabelHeader
protected MultilabelInstancesHeader generateMultilabelHeader(Instances si)
GenerateMultilabelHeader.- Parameters:
si
- single-label Instances
-
nextInstance
public InstanceExample nextInstance()
GenerateML. Generates a multi-label example.- Specified by:
nextInstance
in interfaceExampleStream<Example<Instance>>
- Returns:
- the next example of this stream
-
modifyPriorVector
protected double[] modifyPriorVector(double[] P, double u, Random r, boolean skew)
ModifyPriorVector. A certain number of values will be altered.- Parameters:
P
- the prior distributionu
- the probability of changing P[j]r
- for random numbersskew
- NOTE not currently used- Returns:
- the modified P
-
modifyDependencyMatrix
protected boolean[][] modifyDependencyMatrix(boolean[][] M, double u, Random r)
ModifyDependencyMatrix. A certain number of values will be altered. @NOTE a future improvement would be to detect cycles, since this may lead to inconsistencies. However, due to the rarity of this occurring, and the minimal problems it would cause (and considering that inconsistencies also occr in real datasets) we don't implement this.- Parameters:
M
- a boolean matrixu
- the probability of changing the relationship M[j][k]r
- for random numbers- Returns:
- the modified M
-
generateConditional
protected double[][] generateConditional(double[] P, boolean[][] M)
GenerateConditional. Given the priors distribution and a matrix flagging dependencies, generate a conditional distribution matrix Q; such that: P(i) = Q[i][i] P(i|j) = Q[i][j]- Parameters:
P
- prior distributionM
- dependency matrix (where 1 == dependency)- Returns:
- Q conditional dependency matrix
-
getHeader
public InstancesHeader getHeader()
Description copied from interface:ExampleStream
Gets the header of this stream. This is useful to know attributes and classes. InstancesHeader is an extension of weka.Instances.- Specified by:
getHeader
in interfaceExampleStream<Example<Instance>>
- Returns:
- the header of this stream
-
getPurposeString
public String getPurposeString()
Description copied from class:AbstractOptionHandler
Dictionary with option texts and objects- Specified by:
getPurposeString
in interfaceOptionHandler
- Overrides:
getPurposeString
in classAbstractOptionHandler
- Returns:
- the string with the purpose of this object
-
estimatedRemainingInstances
public long estimatedRemainingInstances()
Description copied from interface:ExampleStream
Gets the estimated number of remaining instances in this stream- Specified by:
estimatedRemainingInstances
in interfaceExampleStream<Example<Instance>>
- Returns:
- the estimated number of instances to get from this stream
-
hasMoreInstances
public boolean hasMoreInstances()
Description copied from interface:ExampleStream
Gets whether this stream has more instances to output. This is useful when reading streams from files.- Specified by:
hasMoreInstances
in interfaceExampleStream<Example<Instance>>
- Returns:
- true if this stream has more instances to output
-
isRestartable
public boolean isRestartable()
Description copied from interface:ExampleStream
Gets whether this stream can restart.- Specified by:
isRestartable
in interfaceExampleStream<Example<Instance>>
- Returns:
- true if this stream can restart
-
getDescription
public void getDescription(StringBuilder sb, int indent)
Description copied from interface:MOAObject
Returns a string representation of this object. Used inAbstractMOAObject.toString
to give a string representation of the object.- Specified by:
getDescription
in interfaceMOAObject
- Parameters:
sb
- the stringbuilder to add the descriptionindent
- the number of characters to indent
-
main
public static void main(String[] args)
-
-