Skip to content

Commit

Permalink
add reproducibility test
Browse files Browse the repository at this point in the history
  • Loading branch information
mnwright committed Oct 6, 2023
1 parent 961198c commit f5e804c
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tests/testthat/test_reproducibility.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
## Tests for cross-platform reproducibility

library(ranger)
context("ranger_repro")

test_that("returns same predictions as before, R seed", {
set.seed(2023)
rf <- ranger(Species ~ ., iris, probability = TRUE)
pred <- predict(rf, iris)

expect_equal(pred$predictions[148:150, 3], c(1.0, 0.9940865, 0.9197802), tolerance = 1e-5)
})

test_that("returns same predictions as before, cpp seed", {
set.seed(2023)
rf <- ranger(Species ~ ., iris, probability = TRUE, seed = 2023)
pred <- predict(rf, iris, seed = 2023)

expect_equal(pred$predictions[148:150, 3], c(1.0000000, 0.9919810, 0.9377452), tolerance = 1e-5)
})

0 comments on commit f5e804c

Please sign in to comment.