Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preparing v0.5.2 #768

Merged
merged 13 commits into from
Apr 24, 2024
8 changes: 5 additions & 3 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mlr3pipelines
Title: Preprocessing Operators and Pipelines for 'mlr3'
Version: 0.5.1-9000
Version: 0.5.2
Authors@R:
c(person(given = "Martin",
family = "Binder",
Expand Down Expand Up @@ -86,14 +86,15 @@ Suggests:
GenSA,
methods,
vtreat,
future
future,
htmlwidgets
ByteCompile: true
Encoding: UTF-8
Config/testthat/edition: 3
Config/testthat/parallel: true
NeedsCompilation: no
Roxygen: list(markdown = TRUE, r6 = FALSE)
RoxygenNote: 7.2.3.9000
RoxygenNote: 7.3.1
VignetteBuilder: knitr
Collate:
'Graph.R'
Expand Down Expand Up @@ -175,6 +176,7 @@ Collate:
'operators.R'
'pipeline_bagging.R'
'pipeline_branch.R'
'pipeline_convert_types.R'
'pipeline_greplicate.R'
'pipeline_ovr.R'
'pipeline_robustify.R'
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,7 @@ export(mlr_graphs)
export(mlr_pipeops)
export(pipeline_bagging)
export(pipeline_branch)
export(pipeline_convert_types)
export(pipeline_greplicate)
export(pipeline_ovr)
export(pipeline_robustify)
Expand Down
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# mlr3pipelines 0.5.1-9000
# mlr3pipelines 0.5.2

* Added new `ppl("convert_types")`.
* Minor documentation fixes.
* Test helpers are now available in `inst/`. These are considered experimental and unstable.

# mlr3pipelines 0.5.1

Expand Down
2 changes: 2 additions & 0 deletions R/GraphLearner.R
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
#' @family Learners
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' library("mlr3")
#'
#' graph = po("pca") %>>% lrn("classif.rpart")
Expand All @@ -76,6 +77,7 @@
#'
#' # Feature importance (of principal components):
#' lr$graph_model$pipeops$classif.rpart$learner_model$importance()
#' \dontshow{ \} }
GraphLearner = R6Class("GraphLearner", inherit = Learner,
public = list(
initialize = function(graph, id = NULL, param_vals = list(), task_type = NULL, predict_type = NULL, clone_graph = TRUE) {
Expand Down
2 changes: 2 additions & 0 deletions R/PipeOpBoxCox.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
#' Only methods inherited from [`PipeOpTaskPreproc`]/[`PipeOp`].
#'
#' @examples
#' \dontshow{ if (requireNamespace("bestNormalize")) \{ }
#' library("mlr3")
#'
#' task = tsk("iris")
Expand All @@ -57,6 +58,7 @@
#' pop$train(list(task))[[1]]$data()
#'
#' pop$state
#' \dontshow{ \} }
#' @family PipeOps
#' @include PipeOpTaskPreproc.R
#' @template seealso_pipeopslist
Expand Down
2 changes: 2 additions & 0 deletions R/PipeOpClassifAvg.R
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@
#' @export
#'
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' \donttest{
#' library("mlr3")
#'
Expand All @@ -77,6 +78,7 @@
#'
#' resample(tsk("iris"), GraphLearner$new(gr), rsmp("holdout"))
#' }
#' \dontshow{ \} }
PipeOpClassifAvg = R6Class("PipeOpClassifAvg",
inherit = PipeOpEnsemble,
public = list(
Expand Down
14 changes: 12 additions & 2 deletions R/PipeOpEncode.R
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#' @format [`R6Class`] object inheriting from [`PipeOpTaskPreprocSimple`]/[`PipeOpTaskPreproc`]/[`PipeOp`].
#'
#' @description
#' Encodes columns of type `factor`, `character` and `ordered`.
#' Encodes columns of type `factor` and `ordered`.
#'
#' Possible encodings are `"one-hot"` encoding, as well as encoding according to `stats::contr.helmert()`, `stats::contr.poly()`,
#' `stats::contr.sum()` and `stats::contr.treatment()`.
Expand All @@ -14,6 +14,8 @@
#'
#' Use the [`PipeOpTaskPreproc`] `$affect_columns` functionality to only encode a subset of columns, or only encode columns of a certain type.
#'
#' `character`-type features can be encoded by converting them `factor` features first, using [`ppl("convert_types", "character", "factor")`][mlr_graphs_convert_types].
#'
#' @section Construction:
#' ```
#' PipeOpEncode$new(id = "encode", param_vals = list())
Expand All @@ -26,7 +28,7 @@
#' @section Input and Output Channels:
#' Input and output channels are inherited from [`PipeOpTaskPreproc`].
#'
#' The output is the input [`Task`][mlr3::Task] with all affected `factor`, `character` or `ordered` parameters encoded according to the `method`
#' The output is the input [`Task`][mlr3::Task] with all affected `factor` and `ordered` parameters encoded according to the `method`
#' parameter.
#'
#' @section State:
Expand Down Expand Up @@ -78,6 +80,14 @@
#'
#' poe$param_set$values$method = "sum"
#' poe$train(list(task))[[1]]$data()
#'
#' # converting character-columns
#' data_chr = data.table::data.table(x = factor(letters[1:3]), y = letters[1:3])
#' task_chr = TaskClassif$new("task_chr", data_chr, "x")
#'
#' goe = ppl("convert_types", "character", "factor") %>>% po("encode")
#'
#' goe$train(task_chr)[[1]]$data()
PipeOpEncode = R6Class("PipeOpEncode",
inherit = PipeOpTaskPreprocSimple,
public = list(
Expand Down
4 changes: 4 additions & 0 deletions R/PipeOpEncodeLmer.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,8 @@
#' @include PipeOpTaskPreproc.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("nloptr")) \{ }
#' \dontshow{ if (requireNamespace("lme4")) \{ }
#' library("mlr3")
#' poe = po("encodelmer")
#'
Expand All @@ -84,6 +86,8 @@
#' poe$train(list(task))[[1]]$data()
#'
#' poe$state
#' \dontshow{ \} }
#' \dontshow{ \} }
PipeOpEncodeLmer = R6Class("PipeOpEncodeLmer",
inherit = PipeOpTaskPreprocSimple,
public = list(
Expand Down
4 changes: 4 additions & 0 deletions R/PipeOpFilter.R
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,8 @@
#' @include PipeOpTaskPreproc.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("mlr3filters")) \{ }
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' library("mlr3")
#' library("mlr3filters")
#' \dontshow{data.table::setDTthreads(1)}
Expand Down Expand Up @@ -107,6 +109,8 @@
#' 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
2 changes: 2 additions & 0 deletions R/PipeOpICA.R
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
#' Only methods inherited from [`PipeOpTaskPreproc`]/[`PipeOp`].
#'
#' @examples
#' \dontshow{ if (requireNamespace("fastICA")) \{ }
#' library("mlr3")
#'
#' task = tsk("iris")
Expand All @@ -82,6 +83,7 @@
#' pop$train(list(task))[[1]]$data()
#'
#' pop$state
#' \dontshow{ \} }
#' @family PipeOps
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
Expand Down
2 changes: 2 additions & 0 deletions R/PipeOpImputeLearner.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@
#' Only methods inherited from [`PipeOpImpute`]/[`PipeOp`].
#'
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' library("mlr3")
#'
#' task = tsk("pima")
Expand All @@ -91,6 +92,7 @@
#' new_task = po$train(list(task = task))[[1]]
#' new_task$missings()
#'
#' \dontshow{ \} }
#' @family PipeOps
#' @family Imputation PipeOps
#' @template seealso_pipeopslist
Expand Down
2 changes: 2 additions & 0 deletions R/PipeOpKernelPCA.R
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,15 @@
#' Only methods inherited from [`PipeOpTaskPreproc`]/[`PipeOp`].
#'
#' @examples
#' \dontshow{ if (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
2 changes: 2 additions & 0 deletions R/PipeOpLearner.R
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@
#' @include PipeOp.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' library("mlr3")
#'
#' task = tsk("iris")
Expand All @@ -80,6 +81,7 @@
#'
#' 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
2 changes: 2 additions & 0 deletions R/PipeOpLearnerCV.R
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@
#' @include PipeOpTaskPreproc.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' library("mlr3")
#'
#' task = tsk("iris")
Expand All @@ -111,6 +112,7 @@
#' graph$pipeops$classif.rpart$learner$predict_type = "prob"
#'
#' graph$train(task)
#' \dontshow{ \} }
PipeOpLearnerCV = R6Class("PipeOpLearnerCV",
inherit = PipeOpTaskPreproc,
public = list(
Expand Down
4 changes: 4 additions & 0 deletions R/PipeOpNMF.R
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,8 @@
#' Only methods inherited from [`PipeOpTaskPreproc`]/[`PipeOp`].
#'
#' @examples
#' \dontshow{ if (requireNamespace("NMF")) \{ }
#' \dontshow{ if (requireNamespace("MASS")) \{ }
#' if (requireNamespace("NMF")) {
#' library("mlr3")
#'
Expand All @@ -99,6 +101,8 @@
#'
#' pop$state
#' }
#' \dontshow{ \} }
#' \dontshow{ \} }
#' @family PipeOps
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
Expand Down
4 changes: 4 additions & 0 deletions R/PipeOpOVR.R
Original file line number Diff line number Diff line change
Expand Up @@ -68,11 +68,13 @@
#' @include PipeOp.R
#' @export
#' @examples
#' \dontshow{ if (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 @@ -174,13 +176,15 @@ mlr_pipeops$add("ovrsplit", PipeOpOVRSplit)
#' @include PipeOpEnsemble.R
#' @export
#' @examples
#' \dontshow{ if (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
2 changes: 2 additions & 0 deletions R/PipeOpProxy.R
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@
#' Only methods inherited from [`PipeOp`].
#'
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' library("mlr3")
#' library("mlr3learners")
#'
Expand All @@ -73,6 +74,7 @@
#' 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
2 changes: 2 additions & 0 deletions R/PipeOpRandomResponse.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
#' @include PipeOp.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' library(mlr3)
#' library(mlr3learners)
#'
Expand All @@ -79,6 +80,7 @@
#' g2$pipeops$regr.lm$learner$predict_type = "se"
#' set.seed(2906)
#' g2$predict(task2)
#' \dontshow{ \} }
PipeOpRandomResponse = R6Class("PipeOpRandomResponse",
inherit = PipeOp,
public = list(
Expand Down
2 changes: 2 additions & 0 deletions R/PipeOpRegrAvg.R
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
#' @include PipeOpEnsemble.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("rpart")) \{ }
#' library("mlr3")
#'
#' # Simple Bagging
Expand All @@ -68,6 +69,7 @@
#' po("classifavg")
#'
#' resample(tsk("iris"), GraphLearner$new(gr), rsmp("holdout"))
#' \dontshow{ \} }
PipeOpRegrAvg = R6Class("PipeOpRegrAvg",
inherit = PipeOpEnsemble,

Expand Down
2 changes: 2 additions & 0 deletions R/PipeOpSmote.R
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
#' @include PipeOpTaskPreproc.R
#' @export
#' @examples
#' \dontshow{ if (requireNamespace("smotefamily")) \{ }
#' library("mlr3")
#'
#' # Create example task
Expand All @@ -67,6 +68,7 @@
#' 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: 4 additions & 0 deletions R/PipeOpTextVectorizer.R
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@
#' Only methods inherited from [`PipeOpTaskPreproc`]/[`PipeOp`].
#'
#' @examples
#' \dontshow{ if (requireNamespace("stopwords")) \{ }
#' \dontshow{ if (requireNamespace("quanteda")) \{ }
#' library("mlr3")
#' library("data.table")
#' # create some text data
Expand All @@ -157,6 +159,8 @@
#' one_line_of_iris$data()
#'
#' pos$predict(list(one_line_of_iris))[[1]]$data()
#' \dontshow{ \} }
#' \dontshow{ \} }
#' @family PipeOps
#' @template seealso_pipeopslist
#' @include PipeOpTaskPreproc.R
Expand Down
Loading