Package opennlp.tools.util.eval
Class CrossValidationPartitioner<E>
java.lang.Object
opennlp.tools.util.eval.CrossValidationPartitioner<E>
Provides access to training and test partitions for n-fold cross validation.
Cross validation is used to evaluate the performance of a classifier when only training data is available. The training set is split into n parts and the training / evaluation is performed n times on these parts. The training partition always consists of n -1 parts and one part is used for testing.
To use the CrossValidationPartioner
a client iterates over the n
TrainingSampleStream
s. Each TrainingSampleStream
represents
one partition and is used first for training and afterwards for testing.
The TestSampleStream
can be obtained from the TrainingSampleStream
with the getTestSampleStream
method.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic class
TheTrainingSampleStream
which iterates over all training elements. -
Constructor Summary
ConstructorsConstructorDescriptionCrossValidationPartitioner
(Collection<E> elements, int numberOfPartitions) Initializes the current instance.CrossValidationPartitioner
(ObjectStream<E> inElements, int numberOfPartitions) Initializes the current instance. -
Method Summary
-
Constructor Details
-
CrossValidationPartitioner
Initializes the current instance.- Parameters:
inElements
-numberOfPartitions
-
-
CrossValidationPartitioner
Initializes the current instance.- Parameters:
elements
-numberOfPartitions
-
-
-
Method Details
-
hasNext
public boolean hasNext()Checks if there are more partitions available. -
next
Retrieves the next training and test partitions.- Throws:
IOException
-
toString
-