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(const LabelMatrix &labelMatrix, IndexIterator indicesBegin, IndexIterator indicesEnd)
Parameters:
  • labelMatrix – A reference to an object of template type LabelMatrix that provides random or row-wise access to the labels of the training examples

  • indicesBegin – 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 hte examples that should be considered

void sampleWeights(BitWeightVector &weightVector, float32 sampleSize, RNG &rng) const

Randomly selects a stratified sample of the available examples and sets their weights to 1, while the remaining weights are set to 0.

Parameters:
  • weightVector – A reference to an object of type BitWeightVector, the weights should be written to

  • sampleSize – The fraction of the available examples to be selected

  • rng – A reference to an object of type RNG, implementing the random number generator to be used

void sampleBiPartition(BiPartition &partition, RNG &rng) const

Randomly splits the available examples into two distinct sets and updates a given BiPartition accordingly.

Parameters:
  • partition – A reference to an object of type BiPartition to be updated

  • rng – A reference to an object of type RNG, implementing the random number generator to be used

Private Members

const uint32 numTotal_
std::vector<std::unique_ptr<std::vector<uint32>>> order_