Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RBatchGenerator_filters_vectors.py File Reference

Detailed Description

View in nbviewer Open in SWAN

##################################################
# This tutorial shows the usage of filters and vectors
# when using RBatchGenerator
##################################################
import ROOT
tree_name = "test_tree"
file_name = (
+ "/machine_learning/RBatchGenerator_filters_vectors_hvector.root"
)
chunk_size = 50 # Defines the size of the chunks
batch_size = 5 # Defines the size of the returned batches
rdataframe = ROOT.RDataFrame(tree_name, file_name)
# Define filters, filters must be named
filteredrdf = rdataframe.Filter("f1 > 30", "first_filter")\
.Filter("f2 < 70", "second_filter")\
.Filter("f3==true", "third_filter")
max_vec_sizes = {"f4": 3, "f5": 2, "f6": 1}
filteredrdf,
batch_size,
chunk_size,
validation_split=0.3,
max_vec_sizes=max_vec_sizes,
shuffle=True,
)
print(f"Columns: {ds_train.columns}")
for i, b in enumerate(ds_train):
print(f"Training batch {i} => {b.shape}")
for i, b in enumerate(ds_validation):
print(f"Validation batch {i} => {b.shape}")
ROOT::Detail::TRangeCast< T, true > TRangeDynCast
TRangeDynCast is an adapter class that allows the typed iteration through a TCollection.
ROOT's RDataFrame offers a modern, high-level interface for analysis of data stored in TTree ,...
Columns: ['f1', 'f2', 'f3', 'f4_0', 'f4_1', 'f4_2', 'f5_0', 'f5_1', 'f6_0']
Training batch 0 => (5, 9)
Training batch 1 => (5, 9)
Validation batch 0 => (5, 9)
Author
Dante Niewenhuis

Definition in file RBatchGenerator_filters_vectors.py.