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] Allow for valid data to be a slice of the training data #6844

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Prev Previous commit
Next Next commit
Adding types for constants
  • Loading branch information
walkerjameschris committed Mar 2, 2025
commit 6b1add4c28a092d098673fc9ef420e8a88367758
16 changes: 8 additions & 8 deletions R-package/tests/testthat/test_basic.R
Original file line number Diff line number Diff line change
@@ -3866,15 +3866,15 @@ test_that("lgb.train() can use slices of an lgb.Dataset for train and valid data
data("iris")

ds <- lgb.Dataset(
as.matrix(iris[, 1:3])
, label = iris[, 4]
as.matrix(iris[, seq_len(3L)])
, label = iris[, 4L]
)

train <- lgb.slice.Dataset(ds, seq(1, 100))
test <- lgb.slice.Dataset(ds, seq(101, 150))
train <- lgb.slice.Dataset(ds, seq_len(100L))
test <- lgb.slice.Dataset(ds, seq_len(50L) + 100L)

test_mat <- as.matrix(iris[101:150, 1:3])
test_label <- iris[101:150, 4]
test_mat <- as.matrix(iris[seq_len(50L) + 100, seq_len(3L)])
test_label <- iris[seq_len(50L) + 100L, 4L]

params <- list(
metric = "l2"
@@ -3891,8 +3891,8 @@ test_that("lgb.train() can use slices of an lgb.Dataset for train and valid data
)

y_hat <- predict(model, newdata = test_mat)
model_l2 <- model$eval_valid()[[1]]$value
independent_l2 <- mean((test_label - y_hat) ** 2)
model_l2 <- model$eval_valid()[[1L]]$value
independent_l2 <- mean((test_label - y_hat) ** 2.0)

expect_equal(model_l2, independent_l2, tolerance = 0.0001)
})
Loading
Oops, something went wrong.