Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RSampler.hxx
Go to the documentation of this file.
1// Author: Martin Føll, University of Oslo (UiO) & CERN 01/2026
2
3/*************************************************************************
4 * Copyright (C) 1995-2026, Rene Brun and Fons Rademakers. *
5 * All rights reserved. *
6 * *
7 * For the licensing terms see $ROOTSYS/LICENSE. *
8 * For the list of contributors see $ROOTSYS/README/CREDITS. *
9 *************************************************************************/
10
11#ifndef TMVA_RSAMPLER
12#define TMVA_RSAMPLER
13
14#include <vector>
15#include <random>
16#include <algorithm>
17
18#include "ROOT/RDataFrame.hxx"
19#include "ROOT/RDF/Utils.hxx"
20#include "ROOT/RVec.hxx"
22#include "ROOT/RLogger.hxx"
23
25// clang-format off
26/**
27\class ROOT::TMVA::Experimental::Internal::RSampler
28\ingroup tmva
29\brief Implementation of different sampling strategies.
30*/
31
32class RSampler {
33private:
34 // clang-format on
35 std::vector<RFlat2DMatrix> &fDatasets;
36 std::string fSampleType;
38 std::size_t fSetSeed;
39 std::size_t fNumEntries;
40
41 std::unique_ptr<RFlat2DMatrixOperators> fTensorOperators;
42public:
43 RSampler(std::vector<RFlat2DMatrix> &datasets, const std::string &sampleType, bool shuffle = true, const std::size_t setSeed = 0)
44 : fDatasets(datasets),
48 {
49 fTensorOperators = std::make_unique<RFlat2DMatrixOperators>(fShuffle, fSetSeed);
50 }
51
52 //////////////////////////////////////////////////////////////////////////
53 /// \brief Collection of sampling types
54 /// \param[in] SampledTensor Tensor with all the sampled entries
56 {
57 if (fSampleType == "random") {
59 }
60 }
61
62 //////////////////////////////////////////////////////////////////////////
63 /// \brief Sample all entries randomly from the datasets
64 /// \param[in] SampledTensor Tensor with all the sampled entries
71
72 std::size_t GetNumEntries() { return fNumEntries;}
73};
74
75} // namespace TMVA::Experimental::Internal
76#endif // TMVA_RSAMPLER
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
RSampler(std::vector< RFlat2DMatrix > &datasets, const std::string &sampleType, bool shuffle=true, const std::size_t setSeed=0)
Definition RSampler.hxx:43
std::vector< RFlat2DMatrix > & fDatasets
Definition RSampler.hxx:35
void RandomSampler(RFlat2DMatrix &SampledTensor)
Sample all entries randomly from the datasets.
Definition RSampler.hxx:65
void Sampler(RFlat2DMatrix &SampledTensor)
Collection of sampling types.
Definition RSampler.hxx:55
std::unique_ptr< RFlat2DMatrixOperators > fTensorOperators
Definition RSampler.hxx:41
Wrapper around ROOT::RVec<float> representing a 2D matrix.