Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
kelly-sovacool committed Feb 16, 2022
2 parents 76a019d + 6572f78 commit 60608a5
Show file tree
Hide file tree
Showing 23 changed files with 36 additions and 27 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# development version

- mikropml now requires R version 4.1.0 or greater due to an update in the randomForest package (#292).
- Fix bug where `cv_times` had no effect on repeats for cross-validation (#291, @kelly-sovacool).

# mikropml 1.2.2

Expand Down
1 change: 1 addition & 0 deletions R/cross_val.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ define_cv <- function(train_data, outcome_colname, hyperparams_list, perf_metric
cv <- caret::trainControl(
method = "repeatedcv",
number = kfold,
repeats = cv_times,
index = cvIndex,
returnResamp = "final",
classProbs = class_probs,
Expand Down
4 changes: 2 additions & 2 deletions data-raw/otu_mini_bin.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ otu_mini_cv <- define_cv(otu_mini_bin_results_glmnet$trained_model$trainingData,
perf_metric_function = caret::multiClassSummary,
class_probs = TRUE,
cv_times = 2,
group = cv_group
groups = cv_group
)
usethis::use_data(otu_mini_cv, overwrite = TRUE)

Expand All @@ -87,7 +87,7 @@ otu_mini_bin_results_svmRadial <- mikropml::run_ml(otu_mini_bin,
)
usethis::use_data(otu_mini_bin_results_svmRadial, overwrite = TRUE)

otu_mini_bin_results_xgbTree <- mikropml::run_ml(otu_mini,
otu_mini_bin_results_xgbTree <- mikropml::run_ml(otu_mini_bin,
"xgbTree",
outcome_colname = "dx",
find_feature_importance = FALSE,
Expand Down
Binary file modified data/otu_mini_bin.rda
Binary file not shown.
Binary file modified data/otu_mini_bin_results_glmnet.rda
Binary file not shown.
Binary file modified data/otu_mini_bin_results_rf.rda
Binary file not shown.
Binary file modified data/otu_mini_bin_results_rpart2.rda
Binary file not shown.
Binary file modified data/otu_mini_bin_results_svmRadial.rda
Binary file not shown.
Binary file modified data/otu_mini_bin_results_xgbTree.rda
Binary file not shown.
Binary file modified data/otu_mini_cont_results_glmnet.rda
Binary file not shown.
Binary file modified data/otu_mini_cont_results_nocv.rda
Binary file not shown.
Binary file modified data/otu_mini_cv.rda
Binary file not shown.
Binary file modified data/otu_mini_multi.rda
Binary file not shown.
Binary file modified data/otu_mini_multi_group.rda
Binary file not shown.
Binary file modified data/otu_mini_multi_results_glmnet.rda
Binary file not shown.
Binary file modified data/otu_small.rda
Binary file not shown.
6 changes: 3 additions & 3 deletions docs/articles/introduction.html

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

4 changes: 2 additions & 2 deletions docs/articles/tuning.html

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

2 changes: 1 addition & 1 deletion docs/pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ articles:
parallel: parallel.html
preprocess: preprocess.html
tuning: tuning.html
last_built: 2022-02-16T00:57Z
last_built: 2022-02-16T16:38Z
urls:
reference: http://www.schlosslab.org/mikropml/reference
article: http://www.schlosslab.org/mikropml/articles
Expand Down
6 changes: 3 additions & 3 deletions docs/reference/get_perf_metric_fn.html

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

8 changes: 4 additions & 4 deletions docs/reference/randomize_feature_order.html

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

26 changes: 14 additions & 12 deletions tests/testthat/test-cross_val.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,20 +21,22 @@ cv_group <- c(

test_that("define_cv works on otu_mini training data with groups", {
set.seed(2019)
expect_equal(
expect_message(
define_cv(otu_mini_bin_results_rf$trained_model$trainingData,
".outcome",
hparams_list,
perf_metric_function,
class_probs = class_probs,
cv_times = 2,
groups = cv_group
),
"Groups will be kept together in CV partitions"
expect_message(
cv <- define_cv(otu_mini_bin_results_rf$trained_model$trainingData,
".outcome",
hparams_list,
perf_metric_function,
class_probs = class_probs,
cv_times = 2,
groups = cv_group
),
otu_mini_cv
"Groups will be kept together in CV partitions"
)
expect_equal(cv, otu_mini_cv)
expect_equal(cv$method, "repeatedcv")
expect_equal(cv$number, 5)
expect_equal(cv$repeats, 2)

expect_message(
define_cv(otu_mini_bin_results_rf$trained_model$trainingData,
".outcome",
Expand Down
5 changes: 5 additions & 0 deletions tests/testthat/test-run_ml.R
Original file line number Diff line number Diff line change
Expand Up @@ -251,3 +251,8 @@ test_that("run_ml catches bad training_frac values", {
"`training_frac` must be a numeric between 0 and 1."
)
})

test_that("models use repeatedcv", {
expect_equal(otu_mini_bin_results_glmnet$trained_model$control$method, "repeatedcv")
expect_equal(otu_mini_bin_results_glmnet$trained_model$control$repeats, 2)
})

0 comments on commit 60608a5

Please sign in to comment.