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

Add capability to get possible max and min values for a model #2737

Merged
merged 26 commits into from
Feb 20, 2020

Conversation

JoanFM
Copy link
Contributor

@JoanFM JoanFM commented Feb 3, 2020

Proposal to provide feature described in: #2736

src/io/tree.cpp Outdated Show resolved Hide resolved
@JoanFM
Copy link
Contributor Author

JoanFM commented Feb 3, 2020

Apparently It fails to compile at linking time, but I do not experience this error locally

@guolinke
Copy link
Collaborator

guolinke commented Feb 3, 2020

You could move the implementation from gbdt_prediction.cpp to gbdt.cpp .

… to upper and lower bound, move implementation to gdbt.cpp
@JoanFM
Copy link
Contributor Author

JoanFM commented Feb 4, 2020

Changed according to comments

Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

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

@JoanFM Thanks for your PR! Please check some comments below:

include/LightGBM/c_api.h Outdated Show resolved Hide resolved
include/LightGBM/tree.h Outdated Show resolved Hide resolved
include/LightGBM/tree.h Outdated Show resolved Hide resolved
src/boosting/gbdt.cpp Outdated Show resolved Hide resolved
src/boosting/gbdt.cpp Outdated Show resolved Hide resolved
include/LightGBM/c_api.h Show resolved Hide resolved
@StrikerRUS
Copy link
Collaborator

@JoanFM New asserts in basic test cause failures for all OSes:

>       self.assertAlmostEqual(bst.upper_bound(), 3.2911086148583832)
E       AssertionError: 3.3182142872462883 != 3.2911086148583832 within 7 places

I guess it's due to you have not the latest commit installed locally. Also, I think 4-6 digits after a dot will be enough to allow future contributions with insignificant changes will not require value adjustments.

@JoanFM
Copy link
Contributor Author

JoanFM commented Feb 5, 2020

Thank you for your comments @StrikerRUS , I have done the changes, I hope it helps

Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

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

Some minor comments before merging.

Also, ping @jameslamb as I'm a little bit confused by function names in R (trailing _).

src/c_api.cpp Outdated Show resolved Hide resolved
src/io/tree.cpp Outdated Show resolved Hide resolved
src/io/tree.cpp Outdated Show resolved Hide resolved
tests/python_package_test/test_basic.py Outdated Show resolved Hide resolved
tests/python_package_test/test_basic.py Outdated Show resolved Hide resolved
@JoanFM JoanFM requested a review from StrikerRUS February 17, 2020 09:44
Copy link
Collaborator

@StrikerRUS StrikerRUS left a comment

Choose a reason for hiding this comment

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

@JoanFM LGTM! Thanks a lot for your contribution!

@StrikerRUS StrikerRUS requested a review from guolinke February 19, 2020 03:33
@@ -357,6 +357,16 @@ class Booster {
return boosting_->FeatureImportance(num_iteration, importance_type);
}

double UpperBoundValue() const {
std::lock_guard<std::mutex> lock(mutex_);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why mutex is needed here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

to guarantee that this value is read while no one is changing any inner value

Copy link
Collaborator

Choose a reason for hiding this comment

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

okay, that is why we need reader/writer locks.

@guolinke guolinke merged commit 18e7de4 into microsoft:master Feb 20, 2020
lower_bound <- 0L
lgb.call(
"LGBM_BoosterGetLowerBoundValue_R"
, ret = upper_bound
Copy link
Collaborator

Choose a reason for hiding this comment

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

I was too slow getting to review here, apologies! @guolinke I'm going to make a followup PR with some changes:

  • using trailing _ is very uncommon in R, these methods should be called upper_bound() and lower_bound()
  • there is a bug on this line...return of the call to LGBM_BoosterGetLowerBoundValue_R should go into lower_bound, not upper_bound
  • there should be unit tests added whenever we introduce new methods in the public API of the package

@lock lock bot locked as resolved and limited conversation to collaborators Apr 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants