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 support to specifying position using position_column parameter #6825

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fixes
  • Loading branch information
NProkoptsev committed Feb 16, 2025
commit 46992dda504fd3b7dbe5b305bf90f5a6514afa9f
11 changes: 9 additions & 2 deletions include/LightGBM/dataset.h
Original file line number Diff line number Diff line change
@@ -252,8 +252,15 @@ class Metadata {
* \return number of different position IDs
*/
inline size_t num_position_ids() const {
size_t max = *std::max_element(positions_.begin(), positions_.end());
return max + 1;
if (!positions_.empty()) {
size_t max = *std::max_element(positions_.begin(), positions_.end());
return max + 1;
}
else
{
return 0;
}

}

/*!
1 change: 0 additions & 1 deletion src/objective/rank_objective.hpp
Original file line number Diff line number Diff line change
@@ -45,7 +45,6 @@ class RankingObjective : public ObjectiveFunction {
// get position ids
// get number of different position ids
num_position_ids_ = static_cast<data_size_t>(metadata.num_position_ids());
Log::Info("Number of different position ids: %d", num_position_ids_);
// get boundaries
query_boundaries_ = metadata.query_boundaries();
if (query_boundaries_ == nullptr) {
Loading
Oops, something went wrong.