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

[docs] document CLI behavior when label_column is omitted #4485

Merged
merged 1 commit into from
Jul 25, 2021

Conversation

jameslamb
Copy link
Collaborator

Answering this stack overflow question tonight, I wasn't able to figure out from LightGBM's documentation that, when using the CLI, if label_column is omitted from train.conf, LightGBM defaults to using the first column in the training data as the target.

I had to figure this out from source code

  • Dataset.label_idx_ is initialized to 0:
    label_idx_ = 0;
  • Dataset.label_idx_ is only overridden if label_column is provided in the config:
    if (config_.label_column.size() > 0) {
    if (Common::StartsWith(config_.label_column, name_prefix)) {
    std::string name = config_.label_column.substr(name_prefix.size());
    label_idx_ = -1;
    for (int i = 0; i < static_cast<int>(feature_names_.size()); ++i) {
    if (name == feature_names_[i]) {
    label_idx_ = i;
    break;
    }
    }

This PR proposes two small changes to make this clearer for new users of the CLI:

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.

Nice clarification!

@jameslamb jameslamb merged commit fdc582e into master Jul 25, 2021
@jameslamb jameslamb deleted the docs/jlamb branch July 25, 2021 04:05
@github-actions
Copy link

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.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 23, 2023
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.

None yet

2 participants