Skip to content

Commit

Permalink
Merge pull request #833 from mlr-org/examplesif
Browse files Browse the repository at this point in the history
replaced dontshow with examplesif
  • Loading branch information
mb706 authored Oct 8, 2024
2 parents e52460b + df6fff8 commit c823f18
Show file tree
Hide file tree
Showing 75 changed files with 118 additions and 228 deletions.
4 changes: 1 addition & 3 deletions R/GraphLearner.R
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,7 @@
#'
#' @family Learners
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' @examplesIf requireNamespace("rpart")
#' library("mlr3")
#'
#' graph = po("pca") %>>% lrn("classif.rpart")
Expand All @@ -158,7 +157,6 @@
#'
#' # Feature importance (of principal components):
#' lr$graph_model$pipeops$classif.rpart$learner_model$importance()
#' \dontshow{ \} }
GraphLearner = R6Class("GraphLearner", inherit = Learner,
public = list(
impute_selected_features = FALSE,
Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpADAS.R
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("smotefamily")) \{ }
#' @examplesIf requireNamespace("smotefamily")
#' library("mlr3")
#'
#' # Create example task
Expand All @@ -69,7 +68,6 @@
#' adas_result = pop$train(list(task))[[1]]$data()
#' nrow(adas_result)
#' table(adas_result$target)
#' \dontshow{ \} }
PipeOpADAS = R6Class("PipeOpADAS",
inherit = PipeOpTaskPreproc,
public = list(
Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpBLSmote.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,7 @@
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("smotefamily")) \{ }
#' @examplesIf requireNamespace("smotefamily")
#' library("mlr3")
#'
#' # Create example task
Expand All @@ -74,7 +73,6 @@
#' bls_result = pop$train(list(task))[[1]]$data()
#' nrow(bls_result)
#' table(bls_result$result)
#' \dontshow{ \} }
PipeOpBLSmote = R6Class("PipeOpBLSmote",
inherit = PipeOpTaskPreproc,
public = list(
Expand Down
5 changes: 2 additions & 3 deletions R/PipeOpBoxCox.R
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,7 @@
#' @section Methods:
#' Only methods inherited from [`PipeOpTaskPreproc`]/[`PipeOp`].
#'
#' @examples
#' \dontshow{ if (requireNamespace("bestNormalize")) \{ }
#' @examplesIf requireNamespace("bestNormalize")
#' library("mlr3")
#'
#' task = tsk("iris")
Expand All @@ -58,7 +57,7 @@
#' pop$train(list(task))[[1]]$data()
#'
#' pop$state
#' \dontshow{ \} }
#'
#' @family PipeOps
#' @include PipeOpTaskPreproc.R
#' @template seealso_pipeopslist
Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpClassifAvg.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,7 @@
#' @include PipeOpEnsemble.R
#' @export
#'
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' @examplesIf requireNamespace("rpart")
#' \donttest{
#' library("mlr3")
#'
Expand All @@ -78,7 +77,6 @@
#'
#' resample(tsk("iris"), GraphLearner$new(gr), rsmp("holdout"))
#' }
#' \dontshow{ \} }
PipeOpClassifAvg = R6Class("PipeOpClassifAvg",
inherit = PipeOpEnsemble,
public = list(
Expand Down
6 changes: 1 addition & 5 deletions R/PipeOpEncodeLmer.R
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,7 @@
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("nloptr")) \{ }
#' \dontshow{ if (requireNamespace("lme4")) \{ }
#' @examplesIf mlr3misc::require_namespaces(c("nloptr", "lme4"), quietly = TRUE)
#' library("mlr3")
#' poe = po("encodelmer")
#'
Expand All @@ -86,8 +84,6 @@
#' poe$train(list(task))[[1]]$data()
#'
#' poe$state
#' \dontshow{ \} }
#' \dontshow{ \} }
PipeOpEncodeLmer = R6Class("PipeOpEncodeLmer",
inherit = PipeOpTaskPreprocSimple,
public = list(
Expand Down
6 changes: 1 addition & 5 deletions R/PipeOpFilter.R
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,7 @@
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("mlr3filters")) \{ }
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' @examplesIf mlr3misc::require_namespaces(c("mlr3filters", "rpart"), quietly = TRUE)
#' library("mlr3")
#' library("mlr3filters")
#' \dontshow{data.table::setDTthreads(1)}
Expand Down Expand Up @@ -109,8 +107,6 @@
#' learner = GraphLearner$new(gr)
#' rr = resample(task, learner, rsmp("holdout"), store_models = TRUE)
#' rr$learners[[1]]$model$auc$scores
#' \dontshow{ \} }
#' \dontshow{ \} }
PipeOpFilter = R6Class("PipeOpFilter",
inherit = PipeOpTaskPreprocSimple,
public = list(
Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpICA.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,7 @@
#' @section Methods:
#' Only methods inherited from [`PipeOpTaskPreproc`]/[`PipeOp`].
#'
#' @examples
#' \dontshow{ if (requireNamespace("fastICA")) \{ }
#' @examplesIf requireNamespace("fastICA")
#' library("mlr3")
#'
#' task = tsk("iris")
Expand All @@ -83,7 +82,6 @@
#' pop$train(list(task))[[1]]$data()
#'
#' pop$state
#' \dontshow{ \} }
#' @family PipeOps
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpImputeLearner.R
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,7 @@
#' @section Methods:
#' Only methods inherited from [`PipeOpImpute`]/[`PipeOp`].
#'
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' @examplesIf requireNamespace("rpart")
#' library("mlr3")
#'
#' task = tsk("pima")
Expand All @@ -94,7 +93,6 @@
#' new_task = po$train(list(task = task))[[1]]
#' new_task$missings()
#'
#' \dontshow{ \} }
#' @family PipeOps
#' @family Imputation PipeOps
#' @template seealso_pipeopslist
Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpKernelPCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@
#' @section Methods:
#' Only methods inherited from [`PipeOpTaskPreproc`]/[`PipeOp`].
#'
#' @examples
#' \dontshow{ if (requireNamespace("kernlab")) \{ }
#' @examplesIf requireNamespace("kernlab")
#' library("mlr3")
#'
#' task = tsk("iris")
#' pop = po("kernelpca", features = 3) # only keep top 3 components
#'
#' task$data()
#' pop$train(list(task))[[1]]$data()
#' \dontshow{ \} }
#' @family PipeOps
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpLearner.R
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,7 @@
#' @template seealso_pipeopslist
#' @include PipeOp.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' @examplesIf requireNamespace("rpart")
#' library("mlr3")
#'
#' task = tsk("iris")
Expand All @@ -91,7 +90,6 @@
#'
#' lrn_po$train(list(task))
#' lrn_po$predict(list(task))
#' \dontshow{ \} }
PipeOpLearner = R6Class("PipeOpLearner", inherit = PipeOp,
public = list(
initialize = function(learner, id = NULL, param_vals = list()) {
Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpLearnerCV.R
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,7 @@
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' @examplesIf requireNamespace("rpart")
#' library("mlr3")
#'
#' task = tsk("iris")
Expand All @@ -114,7 +113,6 @@
#' graph$pipeops$classif.rpart$learner$predict_type = "prob"
#'
#' graph$train(task)
#' \dontshow{ \} }
PipeOpLearnerCV = R6Class("PipeOpLearnerCV",
inherit = PipeOpTaskPreproc,
public = list(
Expand Down
8 changes: 1 addition & 7 deletions R/PipeOpNMF.R
Original file line number Diff line number Diff line change
Expand Up @@ -87,10 +87,7 @@
#' @section Methods:
#' Only methods inherited from [`PipeOpTaskPreproc`]/[`PipeOp`].
#'
#' @examples
#' \dontshow{ if (requireNamespace("NMF")) \{ }
#' \dontshow{ if (requireNamespace("MASS")) \{ }
#' if (requireNamespace("NMF")) {
#' @examplesIf mlr3misc::require_namespaces(c("NMF", "MASS"), quietly = TRUE)
#' library("mlr3")
#'
#' task = tsk("iris")
Expand All @@ -100,10 +97,7 @@
#' pop$train(list(task))[[1]]$data()
#'
#' pop$state
#' }
#' \dontshow{ try(rm("format.list", envir = .BaseNamespaceEnv$.__S3MethodsTable__.), silent = TRUE) # BiocGenerics overwrites printer for our tables mlr-org/mlr3#1112 }
#' \dontshow{ \} }
#' \dontshow{ \} }
#' @family PipeOps
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpNearmiss.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("themis")) \{ }
#' @examplesIf requireNamespace("themis")
#' library("mlr3")
#'
#' # Create example task
Expand All @@ -70,7 +69,6 @@
#' nearmiss_result = pop$train(list(task))[[1]]$data()
#' nrow(nearmiss_result)
#' table(nearmiss_result$type)
#' \dontshow{ \} }
PipeOpNearmiss = R6Class("PipeOpNearmiss",
inherit = PipeOpTaskPreproc,
public = list(
Expand Down
8 changes: 2 additions & 6 deletions R/PipeOpOVR.R
Original file line number Diff line number Diff line change
Expand Up @@ -67,14 +67,12 @@
#' @template seealso_pipeopslist
#' @include PipeOp.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' @examplesIf requireNamespace("rpart")
#' library(mlr3)
#' task = tsk("iris")
#' po = po("ovrsplit")
#' po$train(list(task))
#' po$predict(list(task))
#' \dontshow{ \} }
PipeOpOVRSplit = R6Class("PipeOpOVRSplit",
inherit = PipeOp,
public = list(
Expand Down Expand Up @@ -175,16 +173,14 @@ mlr_pipeops$add("ovrsplit", PipeOpOVRSplit)
#' @template seealso_pipeopslist
#' @include PipeOpEnsemble.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' @examplesIf requireNamespace("rpart")
#' library(mlr3)
#' task = tsk("iris")
#' gr = po("ovrsplit") %>>% lrn("classif.rpart") %>>% po("ovrunite")
#' gr$train(task)
#' gr$predict(task)
#' gr$pipeops$classif.rpart$learner$predict_type = "prob"
#' gr$predict(task)
#' \dontshow{ \} }
PipeOpOVRUnite = R6Class("PipeOpOVRUnite",
inherit = PipeOpEnsemble,
public = list(
Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpProxy.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@
#' @section Methods:
#' Only methods inherited from [`PipeOp`].
#'
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' @examplesIf requireNamespace("rpart")
#' library("mlr3")
#' library("mlr3learners")
#'
Expand All @@ -74,7 +73,6 @@
#' g$param_set$values$learner.content = lrn("classif.rpart")
#' rr_pca_rpart = resample(task, learner = GraphLearner$new(g), resampling = rsmp("cv", folds = 3))
#' rr_pca_rpart$aggregate(msr("classif.ce"))
#' \dontshow{ \} }
#' @family PipeOps
#' @template seealso_pipeopslist
#' @include PipeOp.R
Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpRandomResponse.R
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@
#' @template seealso_pipeopslist
#' @include PipeOp.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' @examplesIf requireNamespace("rpart")
#' library(mlr3)
#' library(mlr3learners)
#'
Expand All @@ -80,7 +79,6 @@
#' g2$pipeops$regr.lm$learner$predict_type = "se"
#' set.seed(2906)
#' g2$predict(task2)
#' \dontshow{ \} }
PipeOpRandomResponse = R6Class("PipeOpRandomResponse",
inherit = PipeOp,
public = list(
Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpRegrAvg.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,7 @@
#' @template seealso_pipeopslist
#' @include PipeOpEnsemble.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' @examplesIf requireNamespace("rpart")
#' library("mlr3")
#'
#' # Simple Bagging
Expand All @@ -69,7 +68,6 @@
#' po("classifavg")
#'
#' resample(tsk("iris"), GraphLearner$new(gr), rsmp("holdout"))
#' \dontshow{ \} }
PipeOpRegrAvg = R6Class("PipeOpRegrAvg",
inherit = PipeOpEnsemble,

Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpSmote.R
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("smotefamily")) \{ }
#' @examplesIf requireNamespace("smotefamily")
#' library("mlr3")
#'
#' # Create example task
Expand All @@ -68,7 +67,6 @@
#' pop = po("smote")
#' smotedata = pop$train(list(task))[[1]]$data()
#' table(smotedata$result)
#' \dontshow{ \} }
PipeOpSmote = R6Class("PipeOpSmote",
inherit = PipeOpTaskPreproc,
public = list(
Expand Down
4 changes: 1 addition & 3 deletions R/PipeOpSmoteNC.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,8 +59,7 @@
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("themis")) \{ }
#' @examplesIf requireNamespace("themis")
#' library("mlr3")
#'
#' # Create example task
Expand All @@ -77,7 +76,6 @@
#' smotenc_result = pop$train(list(task))[[1]]$data()
#' nrow(smotenc_result)
#' table(smotenc_result$target)
#' \dontshow{ \} }
PipeOpSmoteNC = R6Class("PipeOpSmoteNC",
inherit = PipeOpTaskPreproc,
public = list(
Expand Down
Loading

0 comments on commit c823f18

Please sign in to comment.