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

Detailed Description

View in nbviewer Open in SWAN

##################################################
# This tutorial shows the usage of filters and vectors
# when using the ROOT ML dataloader
##################################################
import ROOT
tree_name = "test_tree"
file_name = ROOT.gROOT.GetTutorialDir().Data() + "/machine_learning/ml_dataloader_filters_vectors_hvector.root"
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,
max_vec_sizes=max_vec_sizes,
shuffle=False,
)
ds_train, ds_validation = dl.train_test_split(test_size=0.3)
print(f"Columns: {ds_train.columns}")
print(f"Training batch {i} => {b.shape}")
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 ml_dataloader_filters_vectors.py.