Skip to content

Commit

Permalink
Merge pull request #748 from imbs-hl/issue747
Browse files Browse the repository at this point in the history
More trees and sample size in test
  • Loading branch information
mnwright authored Nov 5, 2024
2 parents 6e5d6cc + ab8ac2c commit 59cd357
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tests/testthat/test_classweights.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@ test_that("No error if class weights used", {
})

test_that("Prediction accuracy for minority class increases with higher weight", {
n <- 100
n <- 500
x <- rnorm(n)
beta0 <- -3
beta <- 1
y <- factor(rbinom(n, 1, plogis(beta0 + beta * x)))
dat <- data.frame(y = y, x)

rf <- ranger(y ~ ., dat, num.trees = 5, min.node.size = 50, class.weights = c(1, 1))
rf <- ranger(y ~ ., dat, num.trees = 50, min.node.size = 50, class.weights = c(1, 1))
acc_major <- mean((rf$predictions == dat$y)[dat$y == "0"], na.rm = TRUE)
acc_minor <- mean((rf$predictions == dat$y)[dat$y == "1"], na.rm = TRUE)

Expand Down

0 comments on commit 59cd357

Please sign in to comment.