[tutorials][ML] Add RDataLoader tutorial for XGBoost#22847
Conversation
There was a problem hiding this comment.
I'm curious: is there an advantage of using the batching data loader for loading all data at once? RDataFrame.AsNumpy seems completely fine here.
Your new code can maybe be seen as a usage example of the RDataLoader, but I would rather do this only in tutorials where the data is actually loaded in batches. Otherwise, we risk sending the wrong message that getting your ROOT data to Numpy is not as easy as one line RDataFrame.AsNumpy.
|
Fair point. There are a couple of advantages of using the rdataloader though:
So:
My goal at the end is to have a tutorial showing how to do XGBoost training with the RDataLoader |
As you see in the existing tutorial, adding the weights as NumPy arrays is not hard, so I wouldn't really call it an advantage of the data loader.
The same argument I made earlier still applies: even if you merge the
That's not what you show in this tutorial. You're showing how to convert ROOT data to NumPy arrays via the RDataLoader, for which I don't see why you'd do that 🙂 And now the tutorial sends the (what I think wrong) message that the RDataLoader is the right way to do this conversion. And since the XGBoost algo is also not designed to re-read training data in each iteration, but it converts it into an internal quantized representation once in the beginning, there is also no way do directly hook in the data loader into XGBoost training. |
92e8d8a to
e24e8a3
Compare
e24e8a3 to
391a7b2
Compare
|
Fair enough modifying The use case comes from workflows where users want to:
You're correct that for simple one-shot loading, |
| ## This tutorial demonstrates XGBoost training using RDataLoader to load data | ||
| ## directly from ROOT files without intermediate preparation steps. | ||
| ## This is an alternative implementation to tutorial tmva101_Training.py, | ||
| ## which stores intermediate files after train/test splitting | ||
| ## and uses numpy arrays to load data. |
There was a problem hiding this comment.
I would not mention tmva101. Cross-referencing between tutorials has a risk to not age well, in particular here because we definitely have to do something about tmva101: it encourages users to store experimental objects like TMVA::Experimental::RBDT in a ROOT file via ROOT.TMVA.Experimental.SaveXGBoost, without explicitly telling you to not do this for production purposes. Yes, the SaveXGBoost interface is clearly experimental, but it doesn't warn the users that the content of the generated file will also be experimental classes.
| | ml_dataloader_Higgs_Classification.py | Loading batches of events from different files for a data-normalization workflow. | | ||
| | ml_dataloader_resampling.py | Loading batches of events from an imbalanced ROOT dataset and balancing them. | | ||
| | ml_dataloader_resampling.py | Loading batches of events from an imbalanced ROOT dataset and balancing them. | | ||
| | ml_dataloader_XGBoost.py | Training XGBoost directly from remote ROOT files. | |
There was a problem hiding this comment.
| | ml_dataloader_XGBoost.py | Training XGBoost directly from remote ROOT files. | | |
| | ml_dataloader_XGBoost.py | Training classifier models directly from remote ROOT files, shown with an XGBoost example. | |
The pattern you show generalized very well to other classification algos, so I would make that clear before people ask you to re-write the same tutorial for catboost or sckit-learn algorithms
There was a problem hiding this comment.
Nice, thank you! Just two small suggestions: I'd refrain from mentioning tmva101 and make it more clear that this tutorial is not XGBoost specific: you'd do exactly the same for any other classifier. Maybe even show a different one, like logistic regression from scikit learn. I'd even consider renaming the tutorial to ml_dataloader_classification.py, but actually sticking with XGBoost in the title might make it more attractive... Can't decide for myself 🙂
Test Results 23 files 23 suites 3d 12h 47m 31s ⏱️ For more details on these failures, see this check. Results for commit 391a7b2. |
This Pull request:
Changes:
Adds a new tutorial
ml_dataloader_XGBoost.pydemonstrating XGBoost training using RDataLoader to stream data directly from EOS without intermediate files stored after the shuffling/splitting phase.This tutorial is inspired from the tmva101_Training workflow but eliminates the need for the tmva100_DataPreparation step which splits the dataset in 2 separate training/testing sets and stores 2 intermediate files.