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 aMultiInstanceListwith an array ofInstanceListMultiInstanceList(java.util.List<InstanceList> lists)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(int index, Instance element)booleanadd(Instance instance)Appends the instance to this list without passing the instance through the InstanceList's pipe.booleanadd(Instance instance, double instanceWeight)Appends the instance to this list without passing it through this InstanceList's pipe, assigning it the specified weight.voidclear()java.lang.Objectclone()InstanceListcloneEmpty()protected InstanceListcloneEmptyInto(InstanceList ret)booleancontains(java.lang.Object elem)InstanceList.CrossValidationIteratorcrossValidationIterator(int nfolds)InstanceList.CrossValidationIteratorcrossValidationIterator(int nfolds, int seed)voidensureCapacity(int minCapacity)booleanequals(java.lang.Object o)Instanceget(int index)inthashCode()intindexOf(java.lang.Object elem)booleanisEmpty()java.util.Iterator<Instance>iterator()intlastIndexOf(java.lang.Object elem)java.util.ListIterator<Instance>listIterator()java.util.ListIterator<Instance>listIterator(int index)Instanceremove(int index)booleanremove(Instance instance)booleanremove(java.lang.Object o)Instanceset(int index, Instance instance)voidsetInstance(int index, Instance instance)Replaces theInstanceat positionindexwith a new one.voidsetInstanceWeight(Instance instance, double weight)InstanceListshallowClone()voidshuffle(java.util.Random r)intsize()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 everymth element of this list, starting with the first.InstanceListsubList(double proportion)InstanceListsubList(int start, int end)java.lang.Object[]toArray()<T> T[]toArray(T[] a)java.lang.StringtoString()voidtrimToSize()-
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 aMultiInstanceListwith an array ofInstanceList- Parameters:
lists- Array ofInstanceListto logically combine
-
MultiInstanceList
public MultiInstanceList(java.util.List<InstanceList> lists)
- Parameters:
lists- List ofInstanceListto logically combine
-
-
Method Detail
-
add
public boolean add(Instance instance, double instanceWeight)
Description copied from class:InstanceListAppends the instance to this list without passing it through this InstanceList's pipe, assigning it the specified weight.- Overrides:
addin classInstanceList- Returns:
true
-
add
public boolean add(Instance instance)
Description copied from class:InstanceListAppends 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:
addin interfacejava.util.Collection<Instance>- Specified by:
addin interfacejava.util.List<Instance>- Overrides:
addin classInstanceList- Returns:
true
-
add
public void add(int index, Instance element)- Specified by:
addin interfacejava.util.List<Instance>- Overrides:
addin classInstanceList
-
clear
public void clear()
- Specified by:
clearin interfacejava.util.Collection<Instance>- Specified by:
clearin interfacejava.util.List<Instance>- Overrides:
clearin classInstanceList
-
clone
public java.lang.Object clone()
- Overrides:
clonein classInstanceList
-
cloneEmpty
public InstanceList cloneEmpty()
- Overrides:
cloneEmptyin classInstanceList
-
cloneEmptyInto
protected InstanceList cloneEmptyInto(InstanceList ret)
- Overrides:
cloneEmptyIntoin classInstanceList
-
contains
public boolean contains(java.lang.Object elem)
-
crossValidationIterator
public InstanceList.CrossValidationIterator crossValidationIterator(int nfolds, int seed)
- Overrides:
crossValidationIteratorin classInstanceList
-
crossValidationIterator
public InstanceList.CrossValidationIterator crossValidationIterator(int nfolds)
- Overrides:
crossValidationIteratorin classInstanceList
-
ensureCapacity
public void ensureCapacity(int minCapacity)
- Overrides:
ensureCapacityin 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:
removein classInstanceList
-
remove
public Instance remove(int index)
- Specified by:
removein interfacejava.util.List<Instance>- Overrides:
removein classInstanceList
-
remove
public boolean remove(java.lang.Object o)
-
set
public Instance set(int index, Instance instance)
- Specified by:
setin interfacejava.util.List<Instance>- Overrides:
setin classInstanceList
-
setInstance
public void setInstance(int index, Instance instance)Description copied from class:InstanceListReplaces theInstanceat positionindexwith a new one.- Overrides:
setInstancein classInstanceList
-
setInstanceWeight
public void setInstanceWeight(Instance instance, double weight)
- Overrides:
setInstanceWeightin classInstanceList
-
shallowClone
public InstanceList shallowClone()
- Overrides:
shallowClonein classInstanceList
-
shuffle
public void shuffle(java.util.Random r)
- Overrides:
shufflein classInstanceList
-
size
public int size()
-
split
public InstanceList[] split(double[] proportions)
- Overrides:
splitin classInstanceList
-
split
public InstanceList[] split(java.util.Random r, double[] proportions)
Description copied from class:InstanceListShuffles the elements of this list among several smaller lists.- Overrides:
splitin 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
InstanceListfor each element ofproportions
-
splitInOrder
public InstanceList[] splitInOrder(double[] proportions)
Description copied from class:InstanceListChops this list into several sequential sublists.- Overrides:
splitInOrderin 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
InstanceListfor each element ofproportions
-
splitInOrder
public InstanceList[] splitInOrder(int[] counts)
- Overrides:
splitInOrderin classInstanceList
-
splitInTwoByModulo
public InstanceList[] splitInTwoByModulo(int m)
Description copied from class:InstanceListReturns a pair of new lists such that the first list in the pair contains everymth element of this list, starting with the first. The second list contains all remaining elements.- Overrides:
splitInTwoByModuloin classInstanceList
-
subList
public InstanceList subList(double proportion)
- Overrides:
subListin classInstanceList
-
subList
public InstanceList subList(int start, int end)
- Specified by:
subListin interfacejava.util.List<Instance>- Overrides:
subListin classInstanceList
-
toArray
public java.lang.Object[] toArray()
-
toArray
public <T> T[] toArray(T[] a)
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.util.AbstractCollection<Instance>
-
trimToSize
public void trimToSize()
- Overrides:
trimToSizein classjava.util.ArrayList<Instance>
-
-