Package cc.mallet.types
Class MultiInstanceList
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractList<E>
-
- java.util.ArrayList<Instance>
-
- cc.mallet.types.InstanceList
-
- cc.mallet.types.MultiInstanceList
-
- All Implemented Interfaces:
AlphabetCarrying
,java.io.Serializable
,java.lang.Cloneable
,java.lang.Iterable<Instance>
,java.util.Collection<Instance>
,java.util.List<Instance>
,java.util.RandomAccess
public class MultiInstanceList extends InstanceList
An implementation of InstanceList that logically combines multiple instance lists so that they appear as one list without copying the original lists. This is useful when running cross-validation experiments with large data sets. Any operation that would modify the size of the list is not supported.- Author:
- Michael Bond mbond@gmail.com
- See Also:
InstanceList
, Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class cc.mallet.types.InstanceList
InstanceList.CrossValidationIterator, InstanceList.StratifiedCrossValidationIterator
-
-
Field Summary
-
Fields inherited from class cc.mallet.types.InstanceList
TARGET_PROPERTY
-
-
Constructor Summary
Constructors Constructor Description MultiInstanceList(InstanceList[] lists)
Constructs aMultiInstanceList
with an array ofInstanceList
MultiInstanceList(java.util.List<InstanceList> lists)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(int index, Instance element)
boolean
add(Instance instance)
Appends the instance to this list without passing the instance through the InstanceList's pipe.boolean
add(Instance instance, double instanceWeight)
Appends the instance to this list without passing it through this InstanceList's pipe, assigning it the specified weight.void
clear()
java.lang.Object
clone()
InstanceList
cloneEmpty()
protected InstanceList
cloneEmptyInto(InstanceList ret)
boolean
contains(java.lang.Object elem)
InstanceList.CrossValidationIterator
crossValidationIterator(int nfolds)
InstanceList.CrossValidationIterator
crossValidationIterator(int nfolds, int seed)
void
ensureCapacity(int minCapacity)
boolean
equals(java.lang.Object o)
Instance
get(int index)
int
hashCode()
int
indexOf(java.lang.Object elem)
boolean
isEmpty()
java.util.Iterator<Instance>
iterator()
int
lastIndexOf(java.lang.Object elem)
java.util.ListIterator<Instance>
listIterator()
java.util.ListIterator<Instance>
listIterator(int index)
Instance
remove(int index)
boolean
remove(Instance instance)
boolean
remove(java.lang.Object o)
Instance
set(int index, Instance instance)
void
setInstance(int index, Instance instance)
Replaces theInstance
at positionindex
with a new one.void
setInstanceWeight(Instance instance, double weight)
InstanceList
shallowClone()
void
shuffle(java.util.Random r)
int
size()
InstanceList[]
split(double[] proportions)
InstanceList[]
split(java.util.Random r, double[] proportions)
Shuffles the elements of this list among several smaller lists.InstanceList[]
splitInOrder(double[] proportions)
Chops this list into several sequential sublists.InstanceList[]
splitInOrder(int[] counts)
InstanceList[]
splitInTwoByModulo(int m)
Returns a pair of new lists such that the first list in the pair contains everym
th element of this list, starting with the first.InstanceList
subList(double proportion)
InstanceList
subList(int start, int end)
java.lang.Object[]
toArray()
<T> T[]
toArray(T[] a)
java.lang.String
toString()
void
trimToSize()
-
Methods inherited from class cc.mallet.types.InstanceList
add, add, addAll, addAll, addThruPipe, addThruPipe, getAlphabet, getAlphabets, getDataAlphabet, getDataClass, getFeatureSelection, getInstanceWeight, getInstanceWeight, getPerLabelFeatureSelection, getPipe, getTargetAlphabet, getTargetClass, hideSomeLabels, hideSomeLabels, load, removeSources, removeTargets, sampleWithInstanceWeights, sampleWithReplacement, sampleWithWeights, save, setFeatureSelection, setInstanceWeight, setPerLabelFeatureSelection, setPipe, stratifiedSplit, stratifiedSplitInOrder, targetLabelDistribution, unhideAllLabels
-
Methods inherited from class java.util.ArrayList
forEach, removeAll, removeIf, removeRange, replaceAll, retainAll, sort, spliterator
-
-
-
-
Constructor Detail
-
MultiInstanceList
public MultiInstanceList(InstanceList[] lists)
Constructs aMultiInstanceList
with an array ofInstanceList
- Parameters:
lists
- Array ofInstanceList
to logically combine
-
MultiInstanceList
public MultiInstanceList(java.util.List<InstanceList> lists)
- Parameters:
lists
- List ofInstanceList
to logically combine
-
-
Method Detail
-
add
public boolean add(Instance instance, double instanceWeight)
Description copied from class:InstanceList
Appends the instance to this list without passing it through this InstanceList's pipe, assigning it the specified weight.- Overrides:
add
in classInstanceList
- Returns:
true
-
add
public boolean add(Instance instance)
Description copied from class:InstanceList
Appends the instance to this list without passing the instance through the InstanceList's pipe. The alphabets of this Instance must match the alphabets of this InstanceList.- Specified by:
add
in interfacejava.util.Collection<Instance>
- Specified by:
add
in interfacejava.util.List<Instance>
- Overrides:
add
in classInstanceList
- Returns:
true
-
add
public void add(int index, Instance element)
- Specified by:
add
in interfacejava.util.List<Instance>
- Overrides:
add
in classInstanceList
-
clear
public void clear()
- Specified by:
clear
in interfacejava.util.Collection<Instance>
- Specified by:
clear
in interfacejava.util.List<Instance>
- Overrides:
clear
in classInstanceList
-
clone
public java.lang.Object clone()
- Overrides:
clone
in classInstanceList
-
cloneEmpty
public InstanceList cloneEmpty()
- Overrides:
cloneEmpty
in classInstanceList
-
cloneEmptyInto
protected InstanceList cloneEmptyInto(InstanceList ret)
- Overrides:
cloneEmptyInto
in classInstanceList
-
contains
public boolean contains(java.lang.Object elem)
-
crossValidationIterator
public InstanceList.CrossValidationIterator crossValidationIterator(int nfolds, int seed)
- Overrides:
crossValidationIterator
in classInstanceList
-
crossValidationIterator
public InstanceList.CrossValidationIterator crossValidationIterator(int nfolds)
- Overrides:
crossValidationIterator
in classInstanceList
-
ensureCapacity
public void ensureCapacity(int minCapacity)
- Overrides:
ensureCapacity
in classjava.util.ArrayList<Instance>
-
equals
public boolean equals(java.lang.Object o)
-
get
public Instance get(int index)
-
hashCode
public int hashCode()
-
indexOf
public int indexOf(java.lang.Object elem)
-
isEmpty
public boolean isEmpty()
-
iterator
public java.util.Iterator<Instance> iterator()
-
lastIndexOf
public int lastIndexOf(java.lang.Object elem)
-
listIterator
public java.util.ListIterator<Instance> listIterator()
-
listIterator
public java.util.ListIterator<Instance> listIterator(int index)
-
remove
public boolean remove(Instance instance)
- Overrides:
remove
in classInstanceList
-
remove
public Instance remove(int index)
- Specified by:
remove
in interfacejava.util.List<Instance>
- Overrides:
remove
in classInstanceList
-
remove
public boolean remove(java.lang.Object o)
-
set
public Instance set(int index, Instance instance)
- Specified by:
set
in interfacejava.util.List<Instance>
- Overrides:
set
in classInstanceList
-
setInstance
public void setInstance(int index, Instance instance)
Description copied from class:InstanceList
Replaces theInstance
at positionindex
with a new one.- Overrides:
setInstance
in classInstanceList
-
setInstanceWeight
public void setInstanceWeight(Instance instance, double weight)
- Overrides:
setInstanceWeight
in classInstanceList
-
shallowClone
public InstanceList shallowClone()
- Overrides:
shallowClone
in classInstanceList
-
shuffle
public void shuffle(java.util.Random r)
- Overrides:
shuffle
in classInstanceList
-
size
public int size()
-
split
public InstanceList[] split(double[] proportions)
- Overrides:
split
in classInstanceList
-
split
public InstanceList[] split(java.util.Random r, double[] proportions)
Description copied from class:InstanceList
Shuffles the elements of this list among several smaller lists.- Overrides:
split
in classInstanceList
- Parameters:
r
- The source of randomness to use in shuffling.proportions
- A list of numbers (not necessarily summing to 1) which, when normalized, correspond to the proportion of elements in each returned sublist. This method (and all the split methods) do not transfer the Instance weights to the resulting InstanceLists.- Returns:
- one
InstanceList
for each element ofproportions
-
splitInOrder
public InstanceList[] splitInOrder(double[] proportions)
Description copied from class:InstanceList
Chops this list into several sequential sublists.- Overrides:
splitInOrder
in classInstanceList
- Parameters:
proportions
- A list of numbers corresponding to the proportion of elements in each returned sublist. If not already normalized to sum to 1.0, it will be normalized here.- Returns:
- one
InstanceList
for each element ofproportions
-
splitInOrder
public InstanceList[] splitInOrder(int[] counts)
- Overrides:
splitInOrder
in classInstanceList
-
splitInTwoByModulo
public InstanceList[] splitInTwoByModulo(int m)
Description copied from class:InstanceList
Returns a pair of new lists such that the first list in the pair contains everym
th element of this list, starting with the first. The second list contains all remaining elements.- Overrides:
splitInTwoByModulo
in classInstanceList
-
subList
public InstanceList subList(double proportion)
- Overrides:
subList
in classInstanceList
-
subList
public InstanceList subList(int start, int end)
- Specified by:
subList
in interfacejava.util.List<Instance>
- Overrides:
subList
in classInstanceList
-
toArray
public java.lang.Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractCollection<Instance>
-
trimToSize
public void trimToSize()
- Overrides:
trimToSize
in classjava.util.ArrayList<Instance>
-
-