-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
Pr4 advanced method monotone constraints #3264
Pr4 advanced method monotone constraints #3264
Conversation
58f1536
to
2801b5d
Compare
Thanks @CharlesAuguste , really really appreciate all of your efforts! I apologize for the inconvenience, but can you please merge |
6208bd2
to
6ae08d6
Compare
Thanks for the advice @jameslamb! I rebased on master and it did fix some issues. I still have 3 failing tasks, which I am not sure about. Can you let me know what you think about these? Thanks! |
All tests are failing due to new NOTE from R-package tests on macOS.
@jameslamb I guess we can't do anything with this except changing the condition here, right? LightGBM/.ci/test_r_package.sh Lines 202 to 206 in 7be57d7
|
uuuuugh that "install-size" test from Yes, @CharlesAuguste could you please increment both limits in the code @StrikerRUS pointed to? if [[ $OS_NAME == "linux" ]] && [[ $R_BUILD_TYPE == "cran" ]]; then
ALLOWED_CHECK_NOTES=3
else
ALLOWED_CHECK_NOTES=2
fi I don't want to hold your PR up. Apologies for the inconvenience. |
@jameslamb If I'm not mistaken that error is in So it can be simply
whithout any Refer to #3188 (comment). |
great, even better. I'm ok with that. |
@jameslamb @StrikerRUS that worked thanks! The check-doc task in Travis is still failing, and doesn't seem related to the PR though. Otherwise, I think the PR should be ready for a review. Let me know what you think! Thanks. |
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.
the R CI change looks fine to me, sorry about that!
I'm not qualified to ✅ / ❌ this PR so I'll leave it to other reviewers to comment on the implementation. Thanks for adding this!
.ci/test_r_package.sh
Outdated
else | ||
ALLOWED_CHECK_NOTES=1 | ||
fi | ||
ALLOWED_CHECK_NOTES=2 |
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.
perfect, thank you
@CharlesAuguste is this PR ready to review? |
@guolinke We've reviewed it internally, I think it should be ready, yes. |
@@ -763,7 +764,7 @@ class FeatureHistogram { | |||
template <bool USE_MC, bool USE_L1, bool USE_MAX_OUTPUT, bool USE_SMOOTHING> | |||
static double CalculateSplittedLeafOutput( | |||
double sum_gradients, double sum_hessians, double l1, double l2, | |||
double max_delta_step, const ConstraintEntry& constraints, | |||
double max_delta_step, const BasicConstraint constraints, |
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.
const T&
?
@@ -288,6 +288,7 @@ class FeatureHistogram { | |||
double best_sum_left_gradient = 0; | |||
double best_sum_left_hessian = 0; | |||
double gain_shift; | |||
constraints->InitCumulativeConstraints(true); |
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 think this is only enable when USE_MC
is true?
|
||
if (constraint_update_necessary) { | ||
constraints->Update(t + offset); | ||
} |
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.
please use USE_MC
for efficiency.
template <bool USE_RAND, bool USE_MC, bool USE_L1, bool USE_MAX_OUTPUT, bool USE_SMOOTHING, | ||
bool REVERSE, bool SKIP_DEFAULT_BIN, bool NA_AS_MISSING> | ||
void FindBestThresholdSequentially(double sum_gradient, double sum_hessian, | ||
data_size_t num_data, | ||
const ConstraintEntry& constraints, | ||
FeatureConstraint* constraints, |
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.
don't we really need to change this to an editable object?
I quick through the code, it seems the CumulativeFeatureConstraint
is reset in each split.
A simple solution is to make CumulativeFeatureConstraint mutable
.
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.
Very good advice!
@CharlesAuguste |
80c7d5d
to
4e1adbc
Compare
Should be better now, let me know what you think. Thanks |
@guolinke I also fixed the constraints not being const in feature_histogram.hpp. Let me know what else I can improve in this PR. |
@CharlesAuguste Could you please add LightGBM/include/LightGBM/config.h Lines 444 to 451 in 9503d3f
|
I forgot to update the doc, sorry. @StrikerRUS It is updated now and, and I ran the parameter generator in the helpers. Let me know if you want something different. Additionally we uploaded the report to https://hal.archives-ouvertes.fr/hal-02862802, and are trying to see if we can also upload it to arXiv. Thanks |
Co-authored-by: Nikita Titov <[email protected]>
Co-authored-by: Nikita Titov <[email protected]>
Co-authored-by: Nikita Titov <[email protected]>
Co-authored-by: Nikita Titov <[email protected]>
Co-authored-by: Nikita Titov <[email protected]>
Co-authored-by: Nikita Titov <[email protected]>
5e75625
to
5774cf4
Compare
@guolinke should be good now. I am not sure what caused the failing test. |
constraints_.get(), feature_index, ~(leaf_splits->leaf_index()), | ||
train_data_->FeatureNumBin(feature_index)); | ||
} | ||
|
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.
@CharlesAuguste Could you please fix lint issue which causes CI test to fail?
src/treelearner/serial_tree_learner.cpp:722: Line ends in whitespace. Consider deleting these extra spaces. [whitespace/end_of_line] [4]
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.
@StrikerRUS Sorry about that I missed that line and didn't understand why the job failed. It is al good now!
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.
No problem, thank you!
Epic! Now all we need is a new version release :) |
Btw, very minor nit: I've just noticed, we haven't updated the link to pdf in |
@aldanor Thanks! Unfortunately, it seems that it is impossible to provide a permanent link for English version of the site. When change |
@aldanor @StrikerRUS I am still trying to upload that to arXiv, through HAL, though I have not yet been successful. If you want I can change the link in the documentation to the HAL pdf for now (in another PR), and we will see later if we want to update it again? Thanks |
@CharlesAuguste Maybe let's wait and see if we can get it uploaded to arxiv? If that succeeds, we can open a PR to update a link to that. (For now, as @StrikerRUS says, it probably makes more sense to keep it as it is then) |
@CharlesAuguste @aldanor I believe, it will make sense to update the link right now if there are any actual differences in the content of two files: hosted at HAL and one uploaded in GitHub comments. |
@StrikerRUS you are right, there are minor changes. I will make a PR to update the link now, and we can update it again if we manage to upload to arXiv. Thanks |
OK, great! Thank you! |
This pull request has been automatically locked since there has not been any recent activity since it was closed. To start a new related discussion, open a new issue at https://github.com/microsoft/LightGBM/issues including a reference to this. |
@aldanor @redditur
@guolinke @jameslamb @StrikerRUS
Following PRs #2305, #2717, #2770, and #2939 here is the last PR of the series. #2305 was judged to be not merge-able because it was too big. Therefore, in my ultimate comment I said I would split it into smaller PRs easier to merge. #2717 was some refactoring, #2770 was the intermediate method, #2939 was the monotone penalization, and this PR is about the advanced method.
As a reminder, the basic method over-constrains leaves, and creates "unused space" between them. The intermediate method is smarter in updating the constraints and creates less "space" between the leaves, but it doesn't take into account that depending on thresholds, a leaf on the right and on the left of a monotone splits may not have to constrain each other. This advanced method takes it into account, and recomputes leaves constraints from the beginning when needed. This leads in a more expressive model, with a meaningfully better training loss. More details in the original report https://github.com/microsoft/LightGBM/files/3457826/PR-monotone-constraints-report.pdf. Feel free to ask for more details.
About the code, most changes happen in the monotone_constraints.hpp file, where the new AdvancedLeafConstraints has been added. Tests have been updated to include this new constraining method.
2 things in the original PR that are missing in here:
I am looking forward to your review. Thanks.