public class FoldParser extends Object implements Parser
The k folds are referred to by their indexes, which are 0, 1, ..., k - 1. This index is used to select the pivot fold.
FoldParser.SplitPolicy
Modifier and Type | Class and Description |
---|---|
static class |
FoldParser.SplitPolicy
Immutable type representing the way in which examples are partitioned into folds.
|
Modifier and Type | Field and Description |
---|---|
protected int |
exampleIndex
Keeps track of the index of the next example to be returned.
|
protected int |
examples
The total number of examples coming from
parser . |
protected int |
fold
Keeps track of the current fold; used only in manual splitting.
|
protected boolean |
fromPivot
Whether examples will come from the pivot fold or not.
|
protected int |
K
The total number of folds.
|
protected int |
lowerBound
A lower bound for an index relating to the pivot fold.
|
protected Parser |
parser
The parser whose examples are being filtered.
|
protected int |
pivot
The examples from this fold are exclusively selected for or excluded from the set of examples
returned by this parser.
|
protected int[] |
shuffled
Used only by the random splitting policy to remember which example indexes are in which
folds.
|
protected int |
shuffleIndex
An index pointing into
shuffled . |
protected FoldParser.SplitPolicy |
splitPolicy
The way in which examples are partitioned into folds.
|
protected int |
upperBound
An upper bound for an index relating to the pivot fold.
|
Constructor and Description |
---|
FoldParser(Parser parser,
FoldParser.SplitPolicy split,
int pivot,
boolean f)
Constructor for when you know neither how many examples are in the data nor K, i.e.,
how many folds are in the data.
|
FoldParser(Parser parser,
int K,
FoldParser.SplitPolicy split,
int pivot,
boolean f)
Constructor for when you don't know how many examples are in the data.
|
FoldParser(Parser parser,
int K,
FoldParser.SplitPolicy split,
int pivot,
boolean f,
int e)
Full constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
close()
Frees any resources this parser may be holding.
|
protected boolean |
filter(Object example)
Convenient for determining if the next example should be returned or not.
|
int |
getK()
Retrieves the value of
K , which may have been computed in the constructor if the
splitting policy is manual. |
Parser |
getParser()
Returns the value of
parser . |
int |
getPivot()
Returns the value of
pivot . |
protected void |
increment(Object example)
Changes state to reflect retrieval of the next example from the parser.
|
Object |
next()
Retrieves the next example object.
|
void |
reset()
Sets this parser back to the beginning of the raw data.
|
void |
setFromPivot(boolean f)
Sets the value of
fromPivot , which controls whether examples will be taken from the
pivot fold or from all other folds. |
void |
setPivot(int p)
Sets the pivot fold, which also causes
parser to be reset. |
protected Parser parser
protected int K
protected FoldParser.SplitPolicy splitPolicy
protected int pivot
protected boolean fromPivot
protected int examples
parser
.protected int exampleIndex
protected int fold
protected int lowerBound
exampleIndex
or shuffleIndex
.protected int upperBound
exampleIndex
or shuffleIndex
.protected int[] shuffled
protected int shuffleIndex
shuffled
.public FoldParser(Parser parser, int K, FoldParser.SplitPolicy split, int pivot, boolean f)
parser
- The parser whose examples are being filtered.K
- The total number of folds; this value is ignored if the splitting policy is manual.split
- The way in which examples are partitioned into folds.pivot
- The index of the pivot fold.f
- Whether to extract examples from the pivot.public FoldParser(Parser parser, FoldParser.SplitPolicy split, int pivot, boolean f)
parser
- The parser whose examples are being filtered.split
- The way in which examples are partitioned into folds.pivot
- The index of the pivot fold.f
- Whether to extract examples from the pivot.public FoldParser(Parser parser, int K, FoldParser.SplitPolicy split, int pivot, boolean f, int e)
parser
- The parser whose examples are being filtered.K
- The total number of folds; this value is ignored if the splitting policy is manual.split
- The way in which examples are partitioned into folds.pivot
- The index of the pivot fold.f
- Whether to extract examples from the pivot.e
- The total number of examples coming from parser
, or -1 if unknown.public int getK()
K
, which may have been computed in the constructor if the
splitting policy is manual.public void setFromPivot(boolean f)
fromPivot
, which controls whether examples will be taken from the
pivot fold or from all other folds.f
- The new value for fromPivot
.public void setPivot(int p)
parser
to be reset.p
- The index of the new pivot fold.public int getPivot()
pivot
.public void reset()
pivot
may have
changed.reset
in interface Parser
setPivot(int)
protected boolean filter(Object example)
example
- The next example object.true
iff the next example should be returned.protected void increment(Object example)
example
- The previous example object.public Object next()
Copyright © 2016. All rights reserved.