Skip to content

Commit

Permalink
set n_fold=1, lambda=1 for betteer test performance
Browse files Browse the repository at this point in the history
  • Loading branch information
lgessl committed Dec 14, 2023
1 parent 2c755bd commit 955b91c
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 17 deletions.
8 changes: 4 additions & 4 deletions man/PerfPlotSpec.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions tests/testthat/test-assess_model.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@ test_that("assess_model() works", {
n <- 10

dir <- withr::local_tempdir()
n_fold <- 3
n_fold <- 1
lambda <- 1
data <- generate_mock_data(
n_samples = n,
n_genes = 5,
Expand All @@ -19,14 +20,14 @@ test_that("assess_model() works", {
model_spec_1 <- ModelSpec(
name = "cox-zerosum",
fitter = zeroSum::zeroSum,
optional_fitter_args = list(family = "cox", alpha = 1, nFold = n_fold, zeroSum = FALSE),
optional_fitter_args = list(family = "cox", alpha = 1, nFold = n_fold, lambda = lambda),
response_type = "survival_censored",
base_dir = dir
)
model_spec_2 <- ModelSpec(
name = "cox-lasso",
fitter = zeroSum::zeroSum,
optional_fitter_args = list(family = "binomial", alpha = 1, nFold = n_fold, zeroSum = FALSE),
optional_fitter_args = list(family = "binomial", alpha = 1, nFold = n_fold, lambda = lambda),
response_type = "binary",
base_dir = dir
)
Expand Down
7 changes: 4 additions & 3 deletions tests/testthat/test-assess_multiple_models.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ test_that("assess_multiple_models() works", {
n_samples <- 25
n_genes <- 5
n_na_in_pheno <- 5
n_fold <- 2
n_fold <- 1
lambda <- 1

base_dir <- withr::local_tempdir("data")
data_dir <- file.path(base_dir, "data/mock")
Expand All @@ -23,7 +24,7 @@ test_that("assess_multiple_models() works", {
model_spec_1 <- ModelSpec(
name = "cox-zerosum",
fitter = zeroSum::zeroSum,
optional_fitter_args = list(family = "cox", alpha = 1, nFold = n_fold, zeroSum = FALSE),
optional_fitter_args = list(family = "cox", alpha = 1, nFold = n_fold, lambda = lambda),
response_type = "survival_censored",
include_from_continuous_pheno = NULL,
include_from_discrete_pheno = NULL,
Expand All @@ -34,7 +35,7 @@ test_that("assess_multiple_models() works", {
model_spec_2 <- ModelSpec(
name = "binomial-zerosum",
fitter = zeroSum::zeroSum,
optional_fitter_args = list(family = "binomial", alpha = 1, nFold = n_fold, zeroSum = FALSE),
optional_fitter_args = list(family = "binomial", alpha = 1, nFold = n_fold, lambda = lambda),
response_type = "binary",
include_from_continuous_pheno = "continuous_var",
include_from_discrete_pheno = "discrete_var",
Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test-fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ test_that("fit function works correctly", {
set.seed(4325)
n_samples = 5
n_features = 5
n_fold = 3
n_fold = 1
lambda <- 1

x <- matrix(rnorm(n_samples*n_features), nrow = n_samples)
y <- rnorm(n_samples) |> as.matrix()
Expand All @@ -19,7 +20,7 @@ test_that("fit function works correctly", {
name = "zerosum",
fitter = zeroSum::zeroSum,
response_type = "survival_censored",
optional_fitter_args = list("alpha" = 0.5, nFold = n_fold, zeroSum = FALSE),
optional_fitter_args = list("alpha" = 0.5, nFold = n_fold, lambda = lambda),
pfs_leq = 2.0,
plot_fname = "foo.pdf",
fit_fname = "bar.rds"
Expand Down
5 changes: 3 additions & 2 deletions tests/testthat/test-prepare_and_fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ test_that("prepare_and_fit() works", {
n_genes <- 5
n_na_in_pheno <- 5
n_fold <- 2
lambda <- 1

data <- generate_mock_data(
n_samples = n_samples,
Expand All @@ -21,7 +22,7 @@ test_that("prepare_and_fit() works", {
model_spec_1 <- ModelSpec(
name = "cox-zerosum",
fitter = zeroSum::zeroSum,
optional_fitter_args = list(family = "cox", alpha = 1, nFold = n_fold, zeroSum = FALSE),
optional_fitter_args = list(family = "cox", alpha = 1, nFold = n_fold, lambda = lambda),
response_type = "survival_censored",
include_from_continuous_pheno = NULL,
include_from_discrete_pheno = NULL,
Expand All @@ -30,7 +31,7 @@ test_that("prepare_and_fit() works", {
model_spec_2 <- ModelSpec(
name = "binomial-zerosum",
fitter = zeroSum::zeroSum,
optional_fitter_args = list(family = "binomial", alpha = 1, nFold = n_fold, zeroSum = FALSE),
optional_fitter_args = list(family = "binomial", alpha = 1, nFold = n_fold, lambda = lambda),
response_type = "binary",
include_from_continuous_pheno = "continuous_var",
include_from_discrete_pheno = "discrete_var",
Expand Down
7 changes: 4 additions & 3 deletions tests/testthat/test-prepare_and_predict.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ test_that("prepare_and_fit", {
n_samples <- 30
n_genes <- 5
n_na_in_pheno <- 5
n_fold <- 2
n_fold <- 1
lambda <- 1

data <- generate_mock_data(
n_samples = n_samples,
Expand All @@ -20,7 +21,7 @@ test_that("prepare_and_fit", {
model_spec_1 <- ModelSpec(
name = "cox-zerosum",
fitter = zeroSum::zeroSum,
optional_fitter_args = list(family = "cox", alpha = 1, nFold = n_fold, zeroSum = FALSE),
optional_fitter_args = list(family = "cox", alpha = 1, nFold = n_fold, lambda = lambda),
response_type = "survival_censored",
include_from_continuous_pheno = NULL,
include_from_discrete_pheno = NULL,
Expand All @@ -30,7 +31,7 @@ test_that("prepare_and_fit", {
model_spec_2 <- ModelSpec(
name = "binomial-zerosum",
fitter = zeroSum::zeroSum,
optional_fitter_args = list(family = "binomial", alpha = 1, nFold = n_fold, zeroSum = FALSE),
optional_fitter_args = list(family = "binomial", alpha = 1, nFold = n_fold, lambda = lambda),
response_type = "binary",
include_from_continuous_pheno = "continuous_var",
include_from_discrete_pheno = "discrete_var",
Expand Down

0 comments on commit 955b91c

Please sign in to comment.