From ab8ac2cfa862b0669736fff0d3b21e78ae1025a5 Mon Sep 17 00:00:00 2001 From: "Marvin N. Wright" Date: Mon, 4 Nov 2024 16:22:54 +0100 Subject: [PATCH] more trees and sample size in test, fix #747 --- tests/testthat/test_classweights.R | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/testthat/test_classweights.R b/tests/testthat/test_classweights.R index 65c73c0b2..9a1896eff 100644 --- a/tests/testthat/test_classweights.R +++ b/tests/testthat/test_classweights.R @@ -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)