11#ifndef ROOT_INTERNAL_ML_RSAMPLER
12#define ROOT_INTERNAL_ML_RSAMPLER
22class RFlat2DMatrixOperators;
36 std::vector<std::vector<std::size_t>> &
fRows;
56 RSampler(
const RFlat2DMatrix &dataset, std::vector<std::vector<std::size_t>> &rows,
const std::string &sampleType,
57 float sampleRatio,
bool replacement =
false,
bool shuffle =
true, std::size_t setSeed = 0);
74 std::size_t numResampled,
const std::vector<std::size_t> &OtherRows);
Implementation of different sampling strategies.
void SampleWithoutReplacement(std::size_t n_samples, std::size_t max)
Add indices without replacement to fSamples.
void SetupRandomUndersampler()
Calculate fNumEntries and major/minor variables for the random undersampler.
void GatherSamples(RFlat2DMatrix &ShuffledTensor, const std::vector< std::size_t > &ResampledRows, std::size_t numResampled, const std::vector< std::size_t > &OtherRows)
Fill the sampled entries: the resampled entries followed by all the other ones, in shuffled order.
void RandomOversampler(RFlat2DMatrix &ShuffledTensor)
Oversample entries randomly from the minority dataset.
std::vector< std::vector< std::size_t > > & fRows
void SampleWithReplacement(std::size_t n_samples, std::size_t max)
Add indices with replacement to fSamples.
void SetupRandomOversampler()
Calculate fNumEntries and major/minor variables for the random oversampler.
const RFlat2DMatrix & fDataset
void SetupSampler()
Calculate fNumEntries and major/minor variables.
std::vector< std::size_t > fSamples
std::size_t GetNumEntries()
std::unique_ptr< RFlat2DMatrixOperators > fTensorOperators
void RandomUndersampler(RFlat2DMatrix &ShuffledTensor)
Undersample entries randomly from the majority dataset.
std::size_t fNumResampledMajor
RSampler(const RFlat2DMatrix &dataset, std::vector< std::vector< std::size_t > > &rows, const std::string &sampleType, float sampleRatio, bool replacement=false, bool shuffle=true, std::size_t setSeed=0)
void Sampler(RFlat2DMatrix &SampledTensor)
Collection of sampling types.
std::size_t fNumResampledMinor
Wrapper around ROOT::RVec<float> representing a 2D matrix.