-
Notifications
You must be signed in to change notification settings - Fork 3.9k
[c++] Add CPU version of standard R-squared metric #7008
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
Conversation
double local_sum_weights = 0.0f; | ||
#pragma omp parallel for num_threads(OMP_NUM_THREADS()) schedule(static) reduction(+:local_sum_weights, sum_label) | ||
for (data_size_t i = 0; i < num_data_; ++i) { | ||
local_sum_weights += weights_[i]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wanted to give a heads up, I originally updated the sum_weights_
data member directly in this for-loop, but this resulted in CI failures on some of the R-package jobs for several builds on Windows with the following error (workflow run, line with specific error):
... error C3028: 'LightGBM::R2Metric::sum_weights_': only a variable or static data member can be used in a data-sharing clause ...
So now, the local_sum_weights
variable is used in the pragma reduction clause and is updated in the loop, and then assigned to sum_weights_
below. I also had to do this for the total_sum_squares_
member by introducing the local_total_sum_squares
variable.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for the explanation, makes sense to me! I can't think of a better way to do this, I think this small allocation is totally fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
blegh I thought I submitted a review yesterday but guess I forgot to click "submit review"!
Thank you so much for this excellent PR! It's rare that I review a PR this large and have 0 comments... but I have 0 comments. You addressed everything I would have asked for... followed the project's style, added lightweight but also very effective tests, updated the docs and that list in the R package.
This is just an awesome PR, and I'm excited to add this to LightGBM. Thanks for your hard work!
I'm not that familiar with C++, so let's see if we can get one other reviewer to look... @borchero could you help us with a review here? |
/gha run r-valgrind |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd been hoping for another reviewer but looks like no one is available, and I'd been waiting to see valgrind results but I realize we don't need those because this PR isn't adding R-package tests anyway.
I'm confident enough in my ability to review these changes that I think we should just merge this.
On a re-review I left one more small suggestion. I'm going to just apply that and then merge this if/when CI passes.
Thanks again for the excellent contribution!
I think the "Optional checks" workflow is going to fail (like this) until we get a successful run of the valgrind workflow on this branch.... because I put up #7008 (comment) but the job wasn't triggered, for the reasons described in #7012 Sorry @nicklamiller , hopefully we'll be able to get #7035 or something similar merged soon and then re-run that workflow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks a lot for this contribution!
I have only two minor comments below:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@nicklamiller Thanks for your latest commit! I don't have any new comments.
Hmm... Errors in CI jobs looks very strange and unrelated to the PR. However, we don't have these errors in @nicklamiller Could you please take a look? |
@nicklamiller So it looks like |
@StrikerRUS Removing I've added back urllib.error.HTTPError: HTTP Error 403: rate limit exceeded
The last reported status from workflow "R valgrind tests" is failure. Commit fixes and rerun the workflow. Since the most recent failure appears to be flaky, I've merged in the master branch and pushed, so hopefully CI passes this time 🤞 |
That I've put up #7035 attempting to fix that (and making it easier to fix such things in the future). |
@StrikerRUS if the latest changes here look ok to you, I'd be ok with you (temporarily!) changing the branch protection to allow merging this PR while |
@nicklamiller Oh, sorry, I missed in resolved thread your perfect description why unrelated tests were failing! Thanks a lot for the investigation and the fix!
Sure, totally fine! |
Close-reopen to fix |
Contributes to: #6983
R2Metric
Metric
instead of a subclass ofRegressionMetric
(like the other regression metrics, which measure loss/error) and used a very similar approach to howAveragePrecisionMetric
is defined inbinary_metric.hpp
:LightGBM/src/metric/binary_metric.hpp
Lines 270 to 385 in 8d7b6f9