File stratified_sampling_example_wise.hpp¶
-
template<typename LabelMatrix, typename IndexIterator>
class ExampleWiseStratification¶ - #include <stratified_sampling_example_wise.hpp>
Implements stratified sampling, where distinct label vectors are treated as individual classes.
- Template Parameters:
LabelMatrix – The type of the label matrix that provides random or row-wise access to the labels of the training examples
IndexIterator – The type of the iterator that provides access to the indices of the examples that should be considered
Public Functions
-
ExampleWiseStratification(std::unique_ptr<RNG> rngPtr, const LabelMatrix &labelMatrix, IndexIterator indicesBegin, IndexIterator indicesEnd)¶
- Parameters:
rngPtr – An unique pointer to an object of type
RNGthat should be used for generating random numberslabelMatrix – A reference to an object of template type
LabelMatrixthat provides random or row-wise access to the labels of the training examplesindicesBegin – An iterator to the beginning of the indices of the examples that should be considered
indicesEnd – An iterator to the end of the indices of the examples that should be considered
-
void sampleWeights(BitWeightVector &weightVector, EqualWeightVector::const_iterator weightIterator, float32 sampleSize, uint32 minSamples, uint32 maxSamples) const¶
Randomly selects a stratified sample of the available examples and sets the corresponding weights in a
BitWeightVectorto the value in the given iterator, while the remaining weights are set to 0.- Parameters:
weightVector – A reference to an object of type
BitWeightVector, the weights should be written toweightIterator – An iterator that provides access to the weights of individual training examples
sampleSize – The fraction of the available examples to be selected
minSamples – The minimum number of examples to be included in the sample. Must be at least 1
maxSamples – The maximum number of examples to be included in the sample. Must be at least
minSamplesor 0, if the number of examples should not be restricted
-
void sampleWeights(DenseWeightVector<float32> &weightVector, DenseWeightVector<float32>::const_iterator weightIterator, float32 sampleSize, uint32 minSamples, uint32 maxSamples) const¶
Randomly selects a stratified sample of the available examples and sets the corresponding weights in a
DenseWeightVector<float32>to the value in the given iterator, while the remaining weights are set to 0.- Parameters:
weightVector – A reference to an object of type
DenseWeightVector<float32>, the weights should be written toweightIterator – An iterator that provides access to the weights of individual training examples
sampleSize – The fraction of the available examples to be selected
minSamples – The minimum number of examples to be included in the sample. Must be at least 1
maxSamples – The maximum number of examples to be included in the sample. Must be at least
minSamplesor 0, if the number of examples should not be restricted
-
void sampleBiPartition(BiPartition &partition) const¶
Randomly splits the available examples into two distinct sets and updates a given
BiPartitionaccordingly.- Parameters:
partition – A reference to an object of type
BiPartitionto be updated