Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
RBatchGenerator_filters_vectors.py
Go to the documentation of this file.
1##################################################
2# This tutorial shows the usage of filters and vectors
3# when using RBatchGenerator
4##################################################
5
6import ROOT
7
8
9tree_name = "test_tree"
10file_name = (
12 + "/tmva/RBatchGenerator_filters_vectors_hvector.root"
13)
14
15chunk_size = 50 # Defines the size of the chunks
16batch_size = 5 # Defines the size of the returned batches
17
18rdataframe = ROOT.RDataFrame(tree_name, file_name)
19
20# Define filters, filters must be named
21filteredrdf = rdataframe.Filter("f1 > 30", "first_filter")\
22 .Filter("f2 < 70", "second_filter")\
23 .Filter("f3==true", "third_filter")
24
25max_vec_sizes = {"f4": 3, "f5": 2, "f6": 1}
26
28 filteredrdf,
29 batch_size,
30 chunk_size,
31 validation_split=0.3,
32 max_vec_sizes=max_vec_sizes,
33 shuffle=True,
34)
35
36print(f"Columns: {ds_train.columns}")
37
38for i, b in enumerate(ds_train):
39 print(f"Training batch {i} => {b.shape}")
40
41for i, b in enumerate(ds_validation):
42 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 ,...