Learn R Programming

mlexperiments (version 0.0.5)

metric_types_helper: metric_types_helper

Description

Prepares the data to be conform with the requirements of the metrics from mlr3measures.

Usage

metric_types_helper(FUN, y, perf_args)

Value

Returns the calculated performance measure.

Arguments

FUN

A metric function, created with metric().

y

The outcome vector.

perf_args

A list. The arguments to call the metric function with.

Details

The mlr3measures R package makes some restrictions on the data type of the ground truth and the predictions, depending on the metric, i.e. the type of the task (regression or classification). Thus, it is necessary to convert the inputs to the metric function accordingly, which is done with this helper function.

Examples

Run this code
set.seed(123)
ground_truth <- sample(0:1, 100, replace = TRUE)
predictions <- sample(0:1, 100, replace = TRUE)
FUN <- metric("acc")

perf_args <- list(
  ground_truth = ground_truth,
  predictions = predictions
)

metric_types_helper(
  FUN = FUN,
  y = ground_truth,
  perf_args = perf_args
)

Run the code above in your browser using DataLab