public class KFoldIterator extends Object implements DataSetIterator
Modifier and Type | Field and Description |
---|---|
protected DataSetPreProcessor |
preProcessor |
Constructor and Description |
---|
KFoldIterator(DataSet singleFold) |
KFoldIterator(int k,
DataSet singleFold)
Create an iterator given the dataset and a value of k (optional, defaults to 10)
If number of samples in the dataset is not a multiple of k, the last fold will have less samples with the rest having the same number of samples.
|
Modifier and Type | Method and Description |
---|---|
boolean |
asyncSupported()
Does this DataSetIterator support asynchronous prefetching of multiple DataSet objects?
Most DataSetIterators do, but in some cases it may not make sense to wrap this iterator in an
iterator that does asynchronous prefetching.
|
int |
batch()
The number of examples in every fold, except the last if totalexamples % k !=0
|
int |
cursor()
cursor value of zero indicates no iterations and the very first fold will be held out as test
cursor value of 1 indicates the the next() call will return all but second fold which will be held out as test
curson value of k-1 indicates the next() call will return all but the last fold which will be held out as test
|
List<String> |
getLabels()
Get dataset iterator record reader labels
|
DataSetPreProcessor |
getPreProcessor()
Returns preprocessors, if defined
|
boolean |
hasNext() |
int |
inputColumns()
Input columns for the dataset
|
int |
lastBatch()
The number of examples in the last fold
if totalexamples % k == 0 same as the number of examples in every other fold
|
DataSet |
next() |
DataSet |
next(int num)
Like the standard next method but allows a
customizable number of examples returned
|
int |
numExamples()
Total number of examples in the dataset
|
void |
remove() |
void |
reset()
Shuffles the dataset and resets to the first fold
|
boolean |
resetSupported()
Is resetting supported by this DataSetIterator? Many DataSetIterators do support resetting,
but some don't
|
void |
setPreProcessor(DataSetPreProcessor preProcessor)
Set a pre processor
|
DataSet |
testFold() |
int |
totalExamples()
Returns total number of examples in the dataset (all k folds)
|
int |
totalOutcomes()
The number of labels for the dataset
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
forEachRemaining
protected DataSetPreProcessor preProcessor
public KFoldIterator(DataSet singleFold)
public KFoldIterator(int k, DataSet singleFold)
k
- number of folds (optional, defaults to 10)singleFold
- DataSet to split into k foldspublic DataSet next(int num) throws UnsupportedOperationException
DataSetIterator
next
in interface DataSetIterator
num
- the number of examplesUnsupportedOperationException
public int totalExamples()
totalExamples
in interface DataSetIterator
public int inputColumns()
DataSetIterator
inputColumns
in interface DataSetIterator
public int totalOutcomes()
DataSetIterator
totalOutcomes
in interface DataSetIterator
public boolean resetSupported()
DataSetIterator
resetSupported
in interface DataSetIterator
public boolean asyncSupported()
DataSetIterator
asyncSupported
in interface DataSetIterator
public void reset()
reset
in interface DataSetIterator
public int batch()
batch
in interface DataSetIterator
public int lastBatch()
public int cursor()
cursor
in interface DataSetIterator
public int numExamples()
DataSetIterator
numExamples
in interface DataSetIterator
public void setPreProcessor(DataSetPreProcessor preProcessor)
DataSetIterator
setPreProcessor
in interface DataSetIterator
preProcessor
- a pre processor to setpublic DataSetPreProcessor getPreProcessor()
DataSetIterator
getPreProcessor
in interface DataSetIterator
public List<String> getLabels()
DataSetIterator
getLabels
in interface DataSetIterator
public DataSet testFold()
Copyright © 2016. All Rights Reserved.