Skip to content
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

[R-package]: add num_trees_per_iter, num_trees, and num_iter methods #6500

Merged
merged 4 commits into from
Jul 3, 2024

Conversation

mayer79
Copy link
Contributor

@mayer79 mayer79 commented Jun 21, 2024

This PR adds to the R Booster class the following methods:

  • num_trees_per_iter(),
  • num_trees(), and
  • num_iter()

Two functions from the C API are required:

  • LGBM_BoosterNumModelPerIteration_R() via LGBM_BoosterNumModelPerIteration() and
  • LGBM_BoosterNumberOfTotalModel_R() via LGBM_BoosterNumberOfTotalModel()

This additionally helps to solve #6380.

Note: With early stopping, the number of (relevant) iterations is kept in Booster$best_iter, while num_trees() and num_iter() are higher.

Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks very much! I support adding these methods on the Booster and not also adding new exported functions for them. And the tests look great.

Will you please just consider my recommendation to use the language "trees" instead of "models"?

R-package/R/lgb.Booster.R Outdated Show resolved Hide resolved
@mayer79 mayer79 changed the title [R-package]: add num_models_per_iter, num_total_models, and num_iter methods [R-package]: add num_trees_per_iter, num_trees, and num_iter methods Jun 22, 2024
Copy link
Collaborator

@jameslamb jameslamb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great, thank you!

@jmoralez do you have time to also review this week? I'd like to hear your opinion on adding this to the R package's public API.

@jameslamb
Copy link
Collaborator

Thanks @jmoralez ! I'll look into the failing CI and merge this.

@jameslamb jameslamb merged commit 7d9106d into microsoft:master Jul 3, 2024
41 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants