Skip to content

R package produces NULL getinfo(dtrain, "group") #11392

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
andrefontenele opened this issue Apr 7, 2025 · 5 comments
Open

R package produces NULL getinfo(dtrain, "group") #11392

andrefontenele opened this issue Apr 7, 2025 · 5 comments

Comments

@andrefontenele
Copy link

andrefontenele commented Apr 7, 2025

While performing cross validation using xgb.cv with a custom_metric, getinfo(dtrain, "group") always returns NULL making it impossible to identify which folder the algorithm is currently using. I have tried this in numerous setups.

@trivialfis
Copy link
Member

If I remember correctly, there's no group meta info. The similar one group_ptr stores the query group for ranking tasks. Could you please elaborate on what you are trying to achieve.

@andrefontenele
Copy link
Author

andrefontenele commented Apr 7, 2025

Thank you so much for the reply. Ah, i see, so group has nothing to see with the fold.

I am trying to calculate a performance metric that depends on some information that is outside the model per se (ie, something that is not in the DMatrix). It is basically a different version of the label (numeric instead of categorical). Is that possible? No information that I can get from getinfo() (ie 'label', 'weight', 'base_margin', 'label_lower_bound', 'label_upper_bound', 'group', 'feature_type', 'feature_name', 'nrow') seems to allow me to identify which fold the cross validation is currently working on, not even if it is in the training or the testing part.

@trivialfis
Copy link
Member

XGBoost computes all folds for each new boosting iteration:

msg <- lapply(bst_folds, function(fd) {

If you want to have custom evaluation, you can try the callback function, which accepts all folds as input:

should_stop <- .execute.cb.after.iter(

@andrefontenele
Copy link
Author

Ok, thank you very much for the reply. Apologies for not understanding the issue properly, but is was really hard to grasp it directly from the documentation and LLMs.

@trivialfis
Copy link
Member

trivialfis commented Apr 8, 2025

No worries. If you have specific questions, feel free to ask. Or, better yet, suggestions for documentation are welcome.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants