-
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
fix behavior for default objective and metric #4660
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,18 +85,15 @@ void GetObjectiveType(const std::unordered_map<std::string, std::string>& params | |
} | ||
} | ||
|
||
void GetMetricType(const std::unordered_map<std::string, std::string>& params, std::vector<std::string>* metric) { | ||
void GetMetricType(const std::unordered_map<std::string, std::string>& params, const std::string& objective, std::vector<std::string>* metric) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. as a general, rule, I like to avoid inserting new arguments in the middle of a function signature. In my experience, I've found that it leads to fewer mistakes when updating the places that call that function. I think this is especially important in C/C++ code, where all arguments are provided positionally. Would you consider adding There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, that was a semantic reason. In all such kind functions ( There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ok makes sense to me, thanks very much for the thorough explanation |
||
std::string value; | ||
if (Config::GetString(params, "metric", &value)) { | ||
std::transform(value.begin(), value.end(), value.begin(), Common::tolower); | ||
ParseMetrics(value, metric); | ||
} | ||
// add names of objective function if not providing metric | ||
if (metric->empty() && value.size() == 0) { | ||
if (Config::GetString(params, "objective", &value)) { | ||
std::transform(value.begin(), value.end(), value.begin(), Common::tolower); | ||
ParseMetrics(value, metric); | ||
} | ||
ParseMetrics(objective, metric); | ||
} | ||
} | ||
|
||
|
@@ -208,8 +205,8 @@ void Config::Set(const std::unordered_map<std::string, std::string>& params) { | |
|
||
GetTaskType(params, &task); | ||
GetBoostingType(params, &boosting); | ||
GetMetricType(params, &metric); | ||
GetObjectiveType(params, &objective); | ||
GetMetricType(params, objective, &metric); | ||
GetDeviceType(params, &device_type); | ||
if (device_type == std::string("cuda")) { | ||
LGBM_config_::current_device = lgbm_device_cuda; | ||
|
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 understand why the
eval_train()
part of this test changed, but how is thiscurrent_iter()
change related to the rest of the PR?I think the line
is testing that a Booster created from a Dataset with a
Predictor
is already considered "fitted", and that thecurrent_iter()
attribute reflects the specific training that was done to produce thatPredictor
.I think just testing that
bst_from_ds
is aBooster
isn't enough to test that the merging here worked:LightGBM/R-package/R/lgb.Booster.R
Lines 55 to 70 in f3987f3
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.
Is line 421 duplicate? (compared with line 419).
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.
That line
expect_equal(bst_from_ds$current_iter(), nrounds)
is still in the test:LightGBM/R-package/tests/testthat/test_lgb.Booster.R
Line 419 in 4ee70d1
As @shiyu1994 correctly noticed that line was duplicated and I removed one duplicate.
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.
ohhhh I see! My mistake, wasn't obvious to me. Thank you.