Skip to content

[R-package] Cannot pass named categorical features to lightgbm() #6000

Closed

Description

@david-cortes

Calling lightgbm() will always end up throwing an error if I pass a matrix with named columns and pass column names for categorical_feature:

library(lightgbm)
data(mtcars)
y <- mtcars$mpg
x <- mtcars[, -1] |> as.matrix()
model <- lightgbm(
    x, y,
    categorical_feature = "cyl"
)
Error in data$set_categorical_feature(categorical_feature) : 
  set_categorical_feature: cannot set categorical feature after freeing raw data,
          please set ‘free_raw_data = FALSE’ when you construct lgb.Dataset

Calling lgb.Dataset beforehand doesn't result in the same error.

This is with the 4.0.0 version in the release tag that says it's for CRAN.

Activity

  1. added a commit that references this issue on Aug 4, 2023
    170a930
  2. github-actions commented on Nov 8, 2023

    @github-actions
    Contributor

    This issue 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.

  3. locked as resolved and limited conversation to collaborators on Nov 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions