R/as_benchmark_result.R

Defines functions as_benchmark_result.ResampleResult as_benchmark_result.BenchmarkResult as_benchmark_result

Documented in as_benchmark_result as_benchmark_result.BenchmarkResult as_benchmark_result.ResampleResult

#' @title Convert to BenchmarkResult
#'
#' @description
#' Convert object to a [BenchmarkResult].
#'
#' @inheritParams as_task
#'
#' @return ([BenchmarkResult]).
#' @export
as_benchmark_result = function(x, ...) {
  UseMethod("as_benchmark_result")
}


#' @rdname as_benchmark_result
#' @export
as_benchmark_result.BenchmarkResult = function(x, ...) { # nolint
  x
}

#' @rdname as_benchmark_result
#' @export
as_benchmark_result.ResampleResult = function(x, ...) { # nolint
  private = get_private(x)
  rdata = private$.data$clone(deep = TRUE)
  if (!is.null(private$.view)) {
    rdata$data$fact = rdata$data$fact[list(private$.view), on = "uhash", nomatch = NULL]
    rdata$sweep()
  }
  BenchmarkResult$new(rdata)
}

Try the mlr3 package in your browser

Any scripts or data that you put into this service are public.

mlr3 documentation built on Nov. 17, 2023, 5:07 p.m.