|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object cc.mallet.types.CrossValidationIterator
public class CrossValidationIterator
An iterator which splits an InstanceList
into n-folds and iterates
over the folds for use in n-fold cross-validation. For each iteration,
list[0] contains a InstanceList
with n-1 folds typically used for
training and list[1] contains an InstanceList
with 1 fold typically
used for validation.
This class uses MultiInstanceList
to avoid creating a new
InstanceList
each iteration.
TODO - currently the distribution is completely random, an improvement would
be to provide a stratified random distribution.
MultiInstanceList
,
InstanceList
,
Serialized FormConstructor Summary | |
---|---|
CrossValidationIterator(InstanceList ilist,
int _nfolds)
Constructs a new n-fold cross-validation iterator |
|
CrossValidationIterator(InstanceList ilist,
int nfolds,
java.util.Random r)
Constructs a new n-fold cross-validation iterator |
Method Summary | |
---|---|
void |
clear()
Calls clear on each fold. |
boolean |
hasNext()
|
InstanceList[] |
next()
Returns the next training/testing split. |
InstanceList[] |
nextSplit()
Returns the next training/testing split. |
InstanceList[] |
nextSplit(int numTrainFolds)
Returns the next training/testing split. |
void |
remove()
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public CrossValidationIterator(InstanceList ilist, int nfolds, java.util.Random r)
ilist
- instance list to split into folds and iterate overnfolds
- number of folds to split InstanceList intor
- The source of randomness to use in shuffling.public CrossValidationIterator(InstanceList ilist, int _nfolds)
ilist
- instance list to split into folds and iterate over_nfolds
- number of folds to split InstanceList intoMethod Detail |
---|
public void clear()
public boolean hasNext()
hasNext
in interface java.util.Iterator<InstanceList[]>
public InstanceList[] nextSplit()
InstanceList
, where
InstanceList[0]
contains n-1 folds for training and
InstanceList[1]
contains 1 fold for testing.public InstanceList[] nextSplit(int numTrainFolds)
InstanceList
, where
InstanceList[0]
contains numTrainingFolds
folds for training and InstanceList[1]
contains
n - numTrainingFolds
folds for testing.public InstanceList[] next()
next
in interface java.util.Iterator<InstanceList[]>
InstanceList
, where
InstanceList[0]
contains n-1 folds for training and
InstanceList[1]
contains 1 fold for testing.Iterator.next()
public void remove()
remove
in interface java.util.Iterator<InstanceList[]>
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |