Skip to content

Commit

Permalink
fix docs
Browse files Browse the repository at this point in the history
  • Loading branch information
mllg committed Feb 21, 2020
1 parent 8067702 commit e0a663d
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 58 deletions.
46 changes: 22 additions & 24 deletions R/BenchmarkResult.R
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
#' Note that all stored objects are accessed by reference.
#' Do not modify any object without cloning it first.
#'
#' @template param_measures
#'
#' @section S3 Methods:
#' * `as.data.table(bmr)`\cr
#' [BenchmarkResult] -> [data.table::data.table()]\cr
Expand Down Expand Up @@ -58,14 +60,14 @@
BenchmarkResult = R6Class("BenchmarkResult",
public = list(

#' @field data [data.table::data.table()]\cr
#' @field data ([data.table::data.table()])\cr
#' Internal data storage with one row per resampling iteration.
#' Can be joined with `$rr_data` by joining on column `"hash"`.
#' We discourage users to directly work with this table.
data = NULL,


#' @field rr_data [data.table::data.table()]\cr
#' @field rr_data ([data.table::data.table()])\cr
#' Internal data storage with one row per [ResampleResult]
#' (instead of one row per resampling iteration as in `$data`).
#'
Expand All @@ -80,7 +82,7 @@ BenchmarkResult = R6Class("BenchmarkResult",
#' @description
#' Creates a new instance of this [R6][R6::R6Class] class.
#'
#' @param data [data.table::data.table()]\cr
#' @param data ([data.table::data.table()])\cr
#' Table with data for one resampling iteration per row, with at least the following columns:
#'
#' * `"task"` ([Task]),
Expand Down Expand Up @@ -133,8 +135,8 @@ BenchmarkResult = R6Class("BenchmarkResult",
#' Fuses a second [BenchmarkResult] into itself, mutating the [BenchmarkResult] in-place.
#' If the second [BenchmarkResult] `bmr` is `NULL`, simply returns `self`.
#'
#' @param bmr [BenchmarkResult]\cr
#' A [BenchmarkResult] object.
#' @param bmr ([BenchmarkResult])\cr
#' A second [BenchmarkResult] object.
#'
#' @return
#' Returns the object itself, but modified **by reference**.
Expand Down Expand Up @@ -165,11 +167,10 @@ BenchmarkResult = R6Class("BenchmarkResult",
#' performance scores as extra columns. These columns are named using the id of
#' the respective [Measure].
#'
#' @param measures [Measure]\cr
#' [Measure](s) to calculate the score for.
#' @param ids `logical(1)`\cr
#' @param ids (`logical(1)`)\cr
#' Adds object ids (`"task_id"`, `"learner_id"`, `"resampling_id"`) as
#' extra character columns for convenient subsetting.
#'
#' @return [data.table::data.table()].
score = function(measures = NULL, ids = TRUE) {
measures = assert_measures(as_measures(measures, task_type = self$task_type))
Expand Down Expand Up @@ -201,22 +202,19 @@ BenchmarkResult = R6Class("BenchmarkResult",
#' For convenience, different flags can be set to extract more
#' information from the returned [ResampleResult]:
#'
#' @param measures ([Measure] | list of [Measure])\cr
#' List of performance measures to calculate.
#'
#' @param uhashes `logical(1)`\cr
#' @param uhashes (`logical(1)`)\cr
#' Adds the uhash values of the [ResampleResult] as extra character
#' column `"uhash"`.
#'
#' @param ids `logical(1)`\cr
#' @param ids (`logical(1)`)\cr
#' Adds object ids (`"task_id"`, `"learner_id"`, `"resampling_id"`) as
#' extra character columns for convenient subsetting.
#'
#' @param params `logical(1)`\cr
#' @param params (`logical(1)`)\cr
#' Adds the hyperparameter values as extra list column `"params"`. You
#' can unnest them with [mlr3misc::unnest()].
#'
#' @param conditions `logical(1)`\cr
#' @param conditions (`logical(1)`)\cr
#' Adds the number of resampling iterations with at least one warning as
#' extra integer column `"warnings"`, and the number of resampling
#' iterations with errors as extra integer column `"errors"`.
Expand Down Expand Up @@ -304,14 +302,14 @@ BenchmarkResult = R6Class("BenchmarkResult",
},

#' @description
#' Retrieve the i-th [ResampleResult], by position or by unique hash
#' `uhash`. `i` and `uhash` are mutually exclusive.
#' Retrieve the i-th [ResampleResult], by position or by unique hash `uhash`.
#' `i` and `uhash` are mutually exclusive.
#'
#' @param i `integer(1)`\cr
#' The desired iteration value.
#' @param i (`integer(1)`)\cr
#' The iteration value to filter for.
#'
#' @param uhash `logical(1)`\cr
#' The desired `ushash` value.
#' @param uhash (`logical(1)`)\cr
#' The `ushash` value to filter for.
#'
#' @return [ResampleResult].
resample_result = function(i = NULL, uhash = NULL) {
Expand Down Expand Up @@ -344,7 +342,7 @@ BenchmarkResult = R6Class("BenchmarkResult",
self$data$task[[1L]]$task_type
},

#' @field tasks [data.table::data.table()]\cr
#' @field tasks ([data.table::data.table()])\cr
#' Table of included [Task]s with three columns:
#'
#' * `"task_hash"` (`character(1)`),
Expand All @@ -355,7 +353,7 @@ BenchmarkResult = R6Class("BenchmarkResult",
unique(self$data[, list(task_hash = hashes(task), task_id = ids(task), task = task)], by = "task_hash")
},

#' @field learners [data.table::data.table()]\cr
#' @field learners ([data.table::data.table()])\cr
#' Table of included [Learner]s with three columns:
#'
#' * `"learner_hash"` (`character(1)`),
Expand All @@ -371,7 +369,7 @@ BenchmarkResult = R6Class("BenchmarkResult",
tab[, learner := lapply(learner, function(x) x$clone(deep = TRUE)$reset())][]
},

#' @field resamplings [data.table::data.table()]\cr
#' @field resamplings ([data.table::data.table()])\cr
#' Table of included [Resampling]s with three columns:
#'
#' * `"resampling_hash"` (`character(1)`),
Expand Down
5 changes: 2 additions & 3 deletions R/Prediction.R
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@
#'
#' Note that this object is usually constructed via a derived classes, e.g. [PredictionClassif] or [PredictionRegr].
#'
#' @template param_measures
#'
#' @section S3 Methods:
#' * `as.data.table(rr)`\cr
#' [Prediction] -> [data.table::data.table()]\cr
Expand Down Expand Up @@ -76,9 +78,6 @@ Prediction = R6Class("Prediction",
#' [Task] and [Learner] may be `NULL` for most measures, but some measures need to extract information
#' from these objects.
#'
#' @param measures ([Measure] | list of [Measure])\cr
#' Performance measures to calculate.
#'
#' @param task ([Task]).
#'
#' @param learner ([Learner]).
Expand Down
9 changes: 3 additions & 6 deletions R/ResampleResult.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,13 @@
#' Note that all stored objects are accessed by reference.
#' Do not modify any object without cloning it first.
#'
#' @template param_measures
#'
#' @section S3 Methods:
#' * `as.data.table(rr)`\cr
#' [ResampleResult] -> [data.table::data.table()]\cr
#' Returns a copy of the internal data.
#'
#' @export
#' @examples
#' task = tsk("iris")
Expand Down Expand Up @@ -114,9 +117,6 @@ ResampleResult = R6Class("ResampleResult",
#' named with the id of the respective measure id.
#' If `measures` is `NULL`, `measures` defaults to the return value of [default_measures()].
#'
#' @param measures ([Measure] | list of [Measure])\cr
#' Performance measures to calculate.
#'
#' @param ids (`logical(1)`)\cr
#' If `ids` is `TRUE`, extra columns with the ids of objects (`"task_id"`, `"learner_id"`, `"resampling_id"`) are added to the returned table.
#' These allow to subset more conveniently.
Expand Down Expand Up @@ -144,9 +144,6 @@ ResampleResult = R6Class("ResampleResult",
#' Calculates and aggregates performance values for all provided measures, according to the respective aggregation function in [Measure].
#' If `measures` is `NULL`, `measures` defaults to the return value of [default_measures()].
#'
#' @param measures ([Measure] | list of [Measure])\cr
#' Performance measures to calculate.
#'
#' @return Named `numeric()`.
aggregate = function(measures = NULL) {
measures = as_measures(measures, task_type = self$task$task_type)
Expand Down
2 changes: 2 additions & 0 deletions man-roxygen/param_measures.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
#' @param measures ([Measure] | list of [Measure])\cr
#' Measure(s) to calculate.
44 changes: 22 additions & 22 deletions man/BenchmarkResult.Rd

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

2 changes: 1 addition & 1 deletion man/Prediction.Rd

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

4 changes: 2 additions & 2 deletions man/ResampleResult.Rd

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

0 comments on commit e0a663d

Please sign in to comment.