Logo ROOT  
Reference Guide
 
Loading...
Searching...
No Matches
ROOT._pythonization._ml_dataloader.RDataLoader Class Reference

Entry point for ML batch loading from a ROOT RDataFrame.

Usage without a validation split::

train = ROOT.Experimental.ML.RDataLoader(df, batch_size=1000, ...)
for x, y in train.as_torch():
    ...

Usage with a validation split::

dl = ROOT.Experimental.ML.RDataLoader(df, batch_size=1000, ...)
train, val = dl.train_test_split(test_size=0.2)
for x, y in train.as_torch():
    ...
for x, y in val.as_numpy():
    ...

Definition at line 605 of file _ml_dataloader.py.

Public Member Functions

None __init__ (self, ROOT.RDF.RNode|Spec|Iterable[ROOT.RDF.RNode|Spec] inputs, *int batch_size=64, int batches_in_memory=10, list[str]|None columns=None, dict[str, int]|None max_vec_sizes=None, float vec_padding=0.0, str|list[str]|None target=None, str weights="", bool shuffle=True, bool drop_remainder=True, int set_seed=0, bool load_eager=False, str sampling_type="", float sampling_ratio=1.0, bool replacement=False)
 Args: inputs: RDataFrame or (dataset_name, files) tuple, or a list of them, to load from.
 
FormattedLoader as_jax (self, str|Any device=None)
 Return an iterable that yields batches as JAX arrays.
 
FormattedLoader as_numpy (self)
 Return an iterable that yields batches as NumPy arrays.
 
tf.data.Dataset as_tensorflow (self)
 Return a tf.data.Dataset over batches as TensorFlow tensors.
 
FormattedLoader as_torch (self, str|torch.device|None device=None)
 Return an iterable that yields batches as PyTorch tensors.
 
list[str] columns (self)
 All column names as they appear in each batch tensor.
 
list[str] feature_columns (self)
 Feature column names (columns minus target and weights).
 
int last_batch_no_of_rows (self)
 Number of rows in the last (remainder) batch, 0 if no remainder.
 
int num_batches (self)
 Total number of batches in this split for one epoch.
 
None save (self, str dataset_name, str|os.PathLike filename, *str output_format="ttree")
 Write this split to disk as it would be loaded for training.
 
list[str] target_columns (self)
 Target column names.
 
Tuple[RDataLoader, RDataLoader] train_test_split (self, float test_size=0.2)
 Partition the dataset into training and validation splits.
 
str weights_column (self)
 Weights column name, or empty string if not set.
 

Public Attributes

 target_columns
 
 weights_column
 

Protected Member Functions

None _ensure_created (self, float test_size=0.0)
 Construct the C++ backend if not already done.
 
RDataLoader _from_internal (cls, _RDataLoader internal, bool is_training)
 Internal factory that creates a split bound RDataLoader sharing an already-constructed C++ backend, train_test_split uses this to return two RDataLoader instances that both point at the same _RDataLoader object.
 

Protected Attributes

 _internal
 
 _is_training
 
 _params
 
 _test_size
 

Member Function Documentation

◆ _ensure_created()

None ROOT._pythonization._ml_dataloader.RDataLoader._ensure_created ( self,
float test_size = 0.0 )
protected

Construct the C++ backend if not already done.

Definition at line 728 of file _ml_dataloader.py.

◆ _from_internal()

RDataLoader ROOT._pythonization._ml_dataloader.RDataLoader._from_internal ( cls,
_RDataLoader internal,
bool is_training )
protected

Internal factory that creates a split bound RDataLoader sharing an already-constructed C++ backend, train_test_split uses this to return two RDataLoader instances that both point at the same _RDataLoader object.

Definition at line 715 of file _ml_dataloader.py.

Member Data Documentation

◆ _internal

ROOT._pythonization._ml_dataloader.RDataLoader._internal
protected

Definition at line 741 of file _ml_dataloader.py.

◆ _is_training

ROOT._pythonization._ml_dataloader.RDataLoader._is_training
protected

Definition at line 778 of file _ml_dataloader.py.

◆ _params

ROOT._pythonization._ml_dataloader.RDataLoader._params
protected

Definition at line 693 of file _ml_dataloader.py.

◆ _test_size

ROOT._pythonization._ml_dataloader.RDataLoader._test_size
protected

Definition at line 742 of file _ml_dataloader.py.

◆ target_columns

ROOT._pythonization._ml_dataloader.RDataLoader.target_columns

Definition at line 869 of file _ml_dataloader.py.

◆ weights_column

ROOT._pythonization._ml_dataloader.RDataLoader.weights_column

Definition at line 882 of file _ml_dataloader.py.


The documentation for this class was generated from the following file: