Loads TTree/RNTuple clusters from one or more RDataFrames into RFlat2DMatrix buffers for ML training and validation.
At construction the loader scans the cluster boundaries of every provided RDataFrame and stores them as a flat list of RClusterRange objects. SplitDataset() then partitions those ranges into training and validation sets according to validationSplit.
(1 - validationSplit) fraction of entries goes to training. At most one cluster is split at the boundary.validationSplit) so both sets draw entries from every part of the dataset. ShuffleTrainingClusters() and ShuffleValidationClusters() re-order the cluster lists at the start of each epoch. A second shuffling step, at the entries level, happens inside LoadTrainingClusterInto() and LoadValidationClusterInto() when loading the data into the tensors.When any RDataFrame carries a filter, the true entry count is not known until the computation graph is executed. In this case SplitDataset() is a no-op and the split is discovered lazily inside LoadTrainingClusterInto() during the first epoch. After the first epoch FinaliseSplitDiscovery() marks the split as stable and all subsequent epochs use the same pre-computed ranges.
Definition at line 80 of file RClusterLoader.hxx.
Public Member Functions | |
| RClusterLoader (std::vector< ROOT::RDF::RNode > &rdfs, const std::vector< std::string > &cols, const std::vector< std::size_t > &vecSizes, float vecPadding, float validationSplit, bool shuffle, std::size_t setSeed) | |
| void | FinaliseSplitDiscovery () |
| Mark the train/val split as finalised after the first epoch. | |
| std::size_t | GetNmTotalClusters () const |
| std::size_t | GetNumChunkCols () const |
| std::size_t | GetNumTrainingClusters () const |
| std::size_t | GetNumTrainingEntries () const |
| std::size_t | GetNumValidationClusters () const |
| std::size_t | GetNumValidationEntries () const |
| const std::vector< RClusterRange > & | GetTrainingClusters () const |
| const std::vector< RClusterRange > & | GetValidationClusters () const |
| bool | IsSplitDiscovered () const |
| void | LoadClusterInto (RFlat2DMatrix &dest, std::size_t rdfIdx, std::uint64_t startRow, std::uint64_t endRow) |
| std::size_t | LoadTrainingClusterInto (RFlat2DMatrix &dest, std::size_t rdfIdx, std::uint64_t startRow, std::uint64_t endRow) |
| Load one training cluster and return the number of rows written. | |
| void | LoadValidationClusterInto (RFlat2DMatrix &dest, std::size_t rdfIdx, std::uint64_t startRow, std::uint64_t endRow) |
Load one validation cluster at the end of dest. | |
| void | ShuffleTrainingClusters (std::size_t epochIdx) |
| Re-order training clusters for the upcoming epoch. | |
| void | ShuffleValidationClusters (std::size_t epochIdx) |
| Re-order validation clusters for the upcoming epoch. | |
| void | SplitDataset () |
| Distribute the clusters into training and validation datasets No-op for filtered RDataFrames, the split is discovered lazily during the first epoch. | |
Private Attributes | |
| std::size_t | fAccumulatedFilteredForTrain {0} |
| std::size_t | fAccumulatedFilteredForVal {0} |
| std::vector< RClusterRange > | fAllClusters |
| std::vector< std::string > | fCols |
| bool | fIsFiltered {false} |
| std::size_t | fNumChunkCols |
| std::size_t | fNumCols |
| std::size_t | fNumTrainingEntries {0} |
| std::size_t | fNumValidationEntries {0} |
| std::vector< ROOT::RDF::RNode > & | fRdfs |
| std::vector< std::size_t > | fRdfSizes |
| std::size_t | fSetSeed |
| bool | fShuffle |
| bool | fSplitDiscovered {false} |
| std::size_t | fSumVecSizes |
| std::size_t | fTotalEntries {0} |
| std::vector< RClusterRange > | fTrainingClusters |
| std::vector< RClusterRange > | fValidationClusters |
| float | fValidationSplit |
| float | fVecPadding |
| std::vector< std::size_t > | fVecSizes |
#include </github/home/ROOT-CI/src/tree/ml/src/RClusterLoader.hxx>
| ROOT::Experimental::Internal::ML::RClusterLoader::RClusterLoader | ( | std::vector< ROOT::RDF::RNode > & | rdfs, |
| const std::vector< std::string > & | cols, | ||
| const std::vector< std::size_t > & | vecSizes, | ||
| float | vecPadding, | ||
| float | validationSplit, | ||
| bool | shuffle, | ||
| std::size_t | setSeed ) |
Definition at line 5 of file RClusterLoader.cxx.
| void ROOT::Experimental::Internal::ML::RClusterLoader::FinaliseSplitDiscovery | ( | ) |
Mark the train/val split as finalised after the first epoch.
Definition at line 285 of file RClusterLoader.cxx.
|
inline |
Definition at line 148 of file RClusterLoader.hxx.
|
inline |
Definition at line 135 of file RClusterLoader.hxx.
|
inline |
Definition at line 143 of file RClusterLoader.hxx.
|
inline |
Definition at line 133 of file RClusterLoader.hxx.
|
inline |
Definition at line 147 of file RClusterLoader.hxx.
|
inline |
Definition at line 134 of file RClusterLoader.hxx.
|
inline |
Definition at line 137 of file RClusterLoader.hxx.
|
inline |
Definition at line 141 of file RClusterLoader.hxx.
|
inline |
Definition at line 129 of file RClusterLoader.hxx.
| void ROOT::Experimental::Internal::ML::RClusterLoader::LoadClusterInto | ( | RFlat2DMatrix & | dest, |
| std::size_t | rdfIdx, | ||
| std::uint64_t | startRow, | ||
| std::uint64_t | endRow ) |
Definition at line 162 of file RClusterLoader.cxx.
| std::size_t ROOT::Experimental::Internal::ML::RClusterLoader::LoadTrainingClusterInto | ( | RFlat2DMatrix & | dest, |
| std::size_t | rdfIdx, | ||
| std::uint64_t | startRow, | ||
| std::uint64_t | endRow ) |
Load one training cluster and return the number of rows written.
Unfiltered: delegates directly to LoadClusterInto() Filtered, epoch 1 (!fSplitDiscovered):
dest. -All subsequent epochs: delegates directly to LoadClusterInto() Definition at line 186 of file RClusterLoader.cxx.
| void ROOT::Experimental::Internal::ML::RClusterLoader::LoadValidationClusterInto | ( | RFlat2DMatrix & | dest, |
| std::size_t | rdfIdx, | ||
| std::uint64_t | startRow, | ||
| std::uint64_t | endRow ) |
Load one validation cluster at the end of dest.
Definition at line 277 of file RClusterLoader.cxx.
| void ROOT::Experimental::Internal::ML::RClusterLoader::ShuffleTrainingClusters | ( | std::size_t | epochIdx | ) |
Re-order training clusters for the upcoming epoch.
Definition at line 141 of file RClusterLoader.cxx.
| void ROOT::Experimental::Internal::ML::RClusterLoader::ShuffleValidationClusters | ( | std::size_t | epochIdx | ) |
Re-order validation clusters for the upcoming epoch.
Definition at line 153 of file RClusterLoader.cxx.
| void ROOT::Experimental::Internal::ML::RClusterLoader::SplitDataset | ( | ) |
Distribute the clusters into training and validation datasets No-op for filtered RDataFrames, the split is discovered lazily during the first epoch.
Definition at line 45 of file RClusterLoader.cxx.
|
private |
Definition at line 105 of file RClusterLoader.hxx.
|
private |
Definition at line 106 of file RClusterLoader.hxx.
|
private |
Definition at line 95 of file RClusterLoader.hxx.
|
private |
Definition at line 84 of file RClusterLoader.hxx.
|
private |
Definition at line 103 of file RClusterLoader.hxx.
|
private |
Definition at line 93 of file RClusterLoader.hxx.
|
private |
Definition at line 91 of file RClusterLoader.hxx.
|
private |
Definition at line 100 of file RClusterLoader.hxx.
|
private |
Definition at line 101 of file RClusterLoader.hxx.
|
private |
Definition at line 82 of file RClusterLoader.hxx.
|
private |
Definition at line 83 of file RClusterLoader.hxx.
|
private |
Definition at line 89 of file RClusterLoader.hxx.
|
private |
Definition at line 88 of file RClusterLoader.hxx.
|
private |
Definition at line 104 of file RClusterLoader.hxx.
|
private |
Definition at line 92 of file RClusterLoader.hxx.
|
private |
Definition at line 99 of file RClusterLoader.hxx.
|
private |
Definition at line 96 of file RClusterLoader.hxx.
|
private |
Definition at line 97 of file RClusterLoader.hxx.
|
private |
Definition at line 87 of file RClusterLoader.hxx.
|
private |
Definition at line 86 of file RClusterLoader.hxx.
|
private |
Definition at line 85 of file RClusterLoader.hxx.