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

[R-package] Accept factor labels and use their levels #5341

Merged
merged 23 commits into from
Feb 14, 2023
Merged
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
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
linter
  • Loading branch information
david-cortes committed Feb 11, 2023
commit d05d2a63b23f36a3d326ad6936ab765c7039fe58
10 changes: 5 additions & 5 deletions R-package/tests/testthat/test_basic.R
Original file line number Diff line number Diff line change
Expand Up @@ -3541,8 +3541,8 @@ test_that("lightgbm() changes objective='auto' appropriately", {
x = model$save_model_to_string()
, split = "\n"
)[[1L]]
expect_true(any(grepl("objective=regression", model_txt_lines)))
expect_false(any(grepl("objective=regression_l1", model_txt_lines)))
expect_true(any(grepl("objective=regression", model_txt_lines, fixed = TRUE)))
expect_false(any(grepl("objective=regression_l1", model_txt_lines, fixed = TRUE)))

# Binary classification
x <- train$data
Expand All @@ -3553,7 +3553,7 @@ test_that("lightgbm() changes objective='auto' appropriately", {
x = model$save_model_to_string()
, split = "\n"
)[[1L]]
expect_true(any(grepl("objective=binary", model_txt_lines)))
expect_true(any(grepl("objective=binary", model_txt_lines, fixed = TRUE)))

# Multi-class classification
data("iris")
Expand All @@ -3566,7 +3566,7 @@ test_that("lightgbm() changes objective='auto' appropriately", {
x = model$save_model_to_string()
, split = "\n"
)[[1L]]
expect_true(any(grepl("objective=multiclass", model_txt_lines)))
expect_true(any(grepl("objective=multiclass", model_txt_lines, fixed = TRUE)))
})

test_that("lightgbm() determines number of classes for non-default multiclass objectives", {
Expand All @@ -3580,7 +3580,7 @@ test_that("lightgbm() determines number of classes for non-default multiclass ob
x = model$save_model_to_string()
, split = "\n"
)[[1L]]
expect_true(any(grepl("objective=multiclassova", model_txt_lines)))
expect_true(any(grepl("objective=multiclassova", model_txt_lines, fixed = TRUE)))
})

test_that("lightgbm() doesn't accept binary classification with non-binary factors", {
Expand Down