|
4 | 4 | #' @format [`R6Class`][R6::R6Class].
|
5 | 5 | #'
|
6 | 6 | #' @description
|
7 |
| -#' A [`Graph`] is a representation of a machine learning pipeline graph. It can be *trained*, and subsequently used for *prediction*. |
| 7 | +#' A `Graph` is a representation of a machine learning pipeline graph. It can be *trained*, and subsequently used for *prediction*. |
8 | 8 | #'
|
9 |
| -#' A [`Graph`] is most useful when used together with [`Learner`][mlr3::Learner] objects encapsulated as [`PipeOpLearner`]. In this case, |
10 |
| -#' the [`Graph`] produces [`Prediction`][mlr3::Prediction] data during its `$predict()` phase and can be used as a [`Learner`][mlr3::Learner] |
11 |
| -#' itself (using the [`GraphLearner`] wrapper). However, the [`Graph`] can also be used without [`Learner`][mlr3::Learner] objects to simply |
| 9 | +#' A `Graph` is most useful when used together with [`Learner`][mlr3::Learner] objects encapsulated as [`PipeOpLearner`]. In this case, |
| 10 | +#' the `Graph` produces [`Prediction`][mlr3::Prediction] data during its `$predict()` phase and can be used as a [`Learner`][mlr3::Learner] |
| 11 | +#' itself (using the [`GraphLearner`] wrapper). However, the `Graph` can also be used without [`Learner`][mlr3::Learner] objects to simply |
12 | 12 | #' perform preprocessing of data, and, in principle, does not even need to handle data at all but can be used for general processes with
|
13 | 13 | #' dependency structure (although the [`PipeOp`]s for this would need to be written).
|
14 | 14 | #'
|
|
18 | 18 | #' ```
|
19 | 19 | #'
|
20 | 20 | #' @section Internals:
|
21 |
| -#' A [`Graph`] is made up of a list of [`PipeOp`]s, and a [`data.table`][data.table::data.table] of edges. Both for training and prediction, the [`Graph`] |
| 21 | +#' A `Graph` is made up of a list of [`PipeOp`]s, and a [`data.table`][data.table::data.table] of edges. Both for training and prediction, the `Graph` |
22 | 22 | #' performs topological sorting of the [`PipeOp`]s and executes their respective `$train()` or `$predict()` functions in order, moving
|
23 | 23 | #' the [`PipeOp`] results along the edges as input to other [`PipeOp`]s.
|
24 | 24 | #'
|
25 | 25 | #' @section Fields:
|
26 | 26 | #' * `pipeops` :: named `list` of [`PipeOp`] \cr
|
27 |
| -#' Contains all [`PipeOp`]s in the [`Graph`], named by the [`PipeOp`]'s `$id`s. |
| 27 | +#' Contains all [`PipeOp`]s in the `Graph`, named by the [`PipeOp`]'s `$id`s. |
28 | 28 | #' * `edges` :: [`data.table`][data.table::data.table] with columns `src_id` (`character`), `src_channel` (`character`), `dst_id` (`character`), `dst_channel` (`character`)\cr
|
29 | 29 | #' Table of connections between the [`PipeOp`]s. A [`data.table`][data.table::data.table]. `src_id` and `dst_id` are `$id`s of [`PipeOp`]s that must be present in
|
30 | 30 | #' the `$pipeops` list. `src_channel` and `dst_channel` must respectively be `$output` and `$input` channel names of the
|
31 | 31 | #' respective [`PipeOp`]s.
|
32 | 32 | #' * `is_trained` :: `logical(1)` \cr
|
33 |
| -#' Is the [`Graph`], i.e. are all of its [`PipeOp`]s, trained, and can the [`Graph`] be used for prediction? |
| 33 | +#' Is the `Graph`, i.e. are all of its [`PipeOp`]s, trained, and can the `Graph` be used for prediction? |
34 | 34 | #' * `lhs` :: `character` \cr
|
35 |
| -#' Ids of the 'left-hand-side' [`PipeOp`]s that have some unconnected input channels and therefore act as [`Graph`] input layer. |
| 35 | +#' Ids of the 'left-hand-side' [`PipeOp`]s that have some unconnected input channels and therefore act as `Graph` input layer. |
36 | 36 | #' * `rhs` :: `character` \cr
|
37 |
| -#' Ids of the 'right-hand-side' [`PipeOp`]s that have some unconnected output channels and therefore act as [`Graph`] output layer. |
| 37 | +#' Ids of the 'right-hand-side' [`PipeOp`]s that have some unconnected output channels and therefore act as `Graph` output layer. |
38 | 38 | #' * `input` :: [`data.table`][data.table::data.table] with columns `name` (`character`), `train` (`character`), `predict` (`character`), `op.id` (`character`), `channel.name` (`character`)\cr
|
39 |
| -#' Input channels of the [`Graph`]. For each channel lists the name, input type during training, input type during prediction, |
| 39 | +#' Input channels of the `Graph`. For each channel lists the name, input type during training, input type during prediction, |
40 | 40 | #' [`PipeOp`] `$id` of the [`PipeOp`] the channel pertains to, and channel name as the [`PipeOp`] knows it.
|
41 | 41 | #' * `output` :: [`data.table`][data.table::data.table] with columns `name` (`character`), `train` (`character`), `predict` (`character`), `op.id` (`character`), `channel.name` (`character`)\cr
|
42 |
| -#' Output channels of the [`Graph`]. For each channel lists the name, output type during training, output type during prediction, |
| 42 | +#' Output channels of the `Graph`. For each channel lists the name, output type during training, output type during prediction, |
43 | 43 | #' [`PipeOp`] `$id` of the [`PipeOp`] the channel pertains to, and channel name as the [`PipeOp`] knows it.
|
44 | 44 | #' * `packages` :: `character`\cr
|
45 |
| -#' Set of all required packages for the various methods in the [`Graph`], a set union of all required packages of all contained |
| 45 | +#' Set of all required packages for the various methods in the `Graph`, a set union of all required packages of all contained |
46 | 46 | #' [`PipeOp`] objects.
|
47 | 47 | #' * `state` :: named `list`\cr
|
48 | 48 | #' Get / Set the `$state` of each of the members of [`PipeOp`].
|
49 | 49 | #' * `param_set` :: [`ParamSet`][paradox::ParamSet]\cr
|
50 | 50 | #' Parameters and parameter constraints. Parameter values are in `$param_set$values`. These are the union of `$param_set`s
|
51 |
| -#' of all [`PipeOp`]s in the [`Graph`]. Parameter names |
52 |
| -#' as seen by the [`Graph`] have the naming scheme `<PipeOp$id>.<PipeOp original parameter name>`. |
| 51 | +#' of all [`PipeOp`]s in the `Graph`. Parameter names |
| 52 | +#' as seen by the `Graph` have the naming scheme `<PipeOp$id>.<PipeOp original parameter name>`. |
53 | 53 | #' Changing `$param_set$values` also propagates the changes directly to the contained
|
54 | 54 | #' [`PipeOp`]s and is an alternative to changing a [`PipeOp`]s `$param_set$values` directly.
|
55 | 55 | #' * `hash` :: `character(1)` \cr
|
56 |
| -#' Stores a checksum calculated on the [`Graph`] configuration, which includes all [`PipeOp`] hashes |
| 56 | +#' Stores a checksum calculated on the `Graph` configuration, which includes all [`PipeOp`] hashes |
57 | 57 | #' (and therefore their `$param_set$values`) and a hash of `$edges`.
|
58 | 58 | #' * `phash` :: `character(1)` \cr
|
59 |
| -#' Stores a checksum calculated on the [`Graph`] configuration, which includes all [`PipeOp`] hashes |
| 59 | +#' Stores a checksum calculated on the `Graph` configuration, which includes all [`PipeOp`] hashes |
60 | 60 | #' *except* their `$param_set$values`, and a hash of `$edges`.
|
61 | 61 | #' * `keep_results` :: `logical(1)`\cr
|
62 | 62 | #' Whether to store intermediate results in the [`PipeOp`]'s `$.result` slot, mostly for debugging purposes. Default `FALSE`.
|
|
70 | 70 | #' `sorted` is `FALSE`, and topologically sorted if `sorted` is `TRUE`.
|
71 | 71 | #' * `add_pipeop(op, clone = TRUE)` \cr
|
72 | 72 | #' ([`PipeOp`] | [`Learner`][mlr3::Learner] | [`Filter`][mlr3filters::Filter] | `...`, `logical(1)`) -> `self` \cr
|
73 |
| -#' Mutates [`Graph`] by adding a [`PipeOp`] to the [`Graph`]. This does not add any edges, so the new [`PipeOp`] |
74 |
| -#' will not be connected within the [`Graph`] at first.\cr |
| 73 | +#' Mutates `Graph` by adding a [`PipeOp`] to the `Graph`. This does not add any edges, so the new [`PipeOp`] |
| 74 | +#' will not be connected within the `Graph` at first.\cr |
75 | 75 | #' Instead of supplying a [`PipeOp`] directly, an object that can naturally be converted to a [`PipeOp`] can also
|
76 | 76 | #' be supplied, e.g. a [`Learner`][mlr3::Learner] or a [`Filter`][mlr3filters::Filter]; see [`as_pipeop()`].
|
77 | 77 | #' The argument given as `op` is cloned if `clone` is `TRUE` (default); to access a `Graph`'s [`PipeOp`]s
|
|
93 | 93 | #' connecting them using [`%>>%`].
|
94 | 94 | #' * `plot(html = FALSE, horizontal = FALSE)` \cr
|
95 | 95 | #' (`logical(1)`, `logical(1)`) -> `NULL` \cr
|
96 |
| -#' Plot the [`Graph`], using either the \pkg{igraph} package (for `html = FALSE`, default) or |
| 96 | +#' Plot the `Graph`, using either the \pkg{igraph} package (for `html = FALSE`, default) or |
97 | 97 | #' the `visNetwork` package for `html = TRUE` producing a [`htmlWidget`][htmlwidgets::htmlwidgets].
|
98 | 98 | #' The [`htmlWidget`][htmlwidgets::htmlwidgets] can be rescaled using [`visOptions`][visNetwork::visOptions].
|
99 | 99 | #' For `html = FALSE`, the orientation of the plotted graph can be controlled through `horizontal`.
|
100 | 100 | #' * `print(dot = FALSE, dotname = "dot", fontsize = 24L)` \cr
|
101 | 101 | #' (`logical(1)`, `character(1)`, `integer(1)`) -> `NULL` \cr
|
102 |
| -#' Print a representation of the [`Graph`] on the console. If `dot` is `FALSE`, output is a table with one row for each contained [`PipeOp`] and |
| 102 | +#' Print a representation of the `Graph` on the console. If `dot` is `FALSE`, output is a table with one row for each contained [`PipeOp`] and |
103 | 103 | #' columns `ID` (`$id` of `PipeOp`), `State` (short representation of `$state` of [`PipeOp`]), `sccssors` ([`PipeOp`]s that
|
104 | 104 | #' take their input directly from the [`PipeOp`] on this line), and `prdcssors` (the [`PipeOp`]s that produce the data
|
105 |
| -#' that is read as input by the [`PipeOp`] on this line). If `dot` is `TRUE`, print a DOT representation of the [`Graph`] on the console. |
| 105 | +#' that is read as input by the [`PipeOp`] on this line). If `dot` is `TRUE`, print a DOT representation of the `Graph` on the console. |
106 | 106 | #' The DOT output can be named via the argument `dotname` and the `fontsize` can also be specified.
|
107 | 107 | #' * `set_names(old, new)` \cr
|
108 | 108 | #' (`character`, `character`) -> `self` \cr
|
|
113 | 113 | #' Pre- or postfix [`PipeOp`]'s existing ids. Both `prefix` and `postfix` default to `""`, i.e. no changes.
|
114 | 114 | #' * `train(input, single_input = TRUE)` \cr
|
115 | 115 | #' (`any`, `logical(1)`) -> named `list`\cr
|
116 |
| -#' Train [`Graph`] by traversing the [`Graph`]s' edges and calling all the [`PipeOp`]'s `$train` methods in turn. |
| 116 | +#' Train `Graph` by traversing the `Graph`s' edges and calling all the [`PipeOp`]'s `$train` methods in turn. |
117 | 117 | #' Return a named `list` of outputs for each unconnected
|
118 |
| -#' [`PipeOp`] out-channel, named according to the [`Graph`]'s `$output` `name` column. During training, the `$state` |
| 118 | +#' [`PipeOp`] out-channel, named according to the `Graph`'s `$output` `name` column. During training, the `$state` |
119 | 119 | #' member of each [`PipeOp`]s will be set and the `$is_trained` slot of the `Graph` (and each individual `PipeOp`) will
|
120 | 120 | #' consequently be set to `TRUE`.\cr
|
121 | 121 | #' If `single_input` is `TRUE`, the `input` value will be sent to each unconnected [`PipeOp`]'s input channel
|
122 |
| -#' (as listed in the [`Graph`]'s `$input`). Typically, `input` should be a [`Task`][mlr3::Task], although this is dependent |
123 |
| -#' on the [`PipeOp`]s in the [`Graph`]. If `single_input` is `FALSE`, then |
124 |
| -#' `input` should be a `list` with the same length as the [`Graph`]'s `$input` table has rows; each list item will be sent |
125 |
| -#' to a corresponding input channel of the [`Graph`]. If `input` is a named `list`, names must correspond to input channel |
| 122 | +#' (as listed in the `Graph`'s `$input`). Typically, `input` should be a [`Task`][mlr3::Task], although this is dependent |
| 123 | +#' on the [`PipeOp`]s in the `Graph`. If `single_input` is `FALSE`, then |
| 124 | +#' `input` should be a `list` with the same length as the `Graph`'s `$input` table has rows; each list item will be sent |
| 125 | +#' to a corresponding input channel of the `Graph`. If `input` is a named `list`, names must correspond to input channel |
126 | 126 | #' names (`$input$name`) and inputs will be sent to the channels by name; otherwise they will be sent to the channels
|
127 | 127 | #' in order in which they are listed in `$input`.
|
128 | 128 | #' * `predict(input, single_input = TRUE)` \cr
|
129 | 129 | #' (`any`, `logical(1)`) -> `list` of `any` \cr
|
130 |
| -#' Predict with the [`Graph`] by calling all the [`PipeOp`]'s `$train` methods. Input and output, as well as the function |
| 130 | +#' Predict with the `Graph` by calling all the [`PipeOp`]'s `$train` methods. Input and output, as well as the function |
131 | 131 | #' of the `single_input` argument, are analogous to `$train()`.
|
132 | 132 | #' * `help(help_type)` \cr
|
133 | 133 | #' (`character(1)`) -> help file\cr
|
|
0 commit comments