detc: DET Curve calculation

View source: R/detc.R

detcR Documentation

DET Curve calculation

Description

From a response and one or more predictors, the function calculates a DET curve for each response-predictor pair. Optionally, it can compute each curve with a confidence interval (CI). Instead of a response and predictors, it can also receive a 'DETs' object to extract existing DET curve results and compute CIs.

Usage

detc(
  response = NULL,
  predictors = NULL,
  dets = NULL,
  names = NULL,
  conf = NULL,
  positive = "",
  parallel = FALSE,
  ncores = detectCores(),
  nboot = NULL,
  plot = FALSE,
  ...
)

Arguments

response

A factor, typically encoded with 0 (healthy, genuine user, signal, normal) and 1 (diseased, impostor user, noise, abnormal). It can also be a dichotomous variable that will be treated as a factor. By default, the second factor level is used as the positive class.

predictors

A matrix whose columns represent the values of each predictor.

dets

A 'DETs' object which will be used to compute the DET curves.

names

A character vector that will be used to set the names of the DET curves. They will also appear in the plot legend.

conf

If present, the confidence level for the DET curve CI, within [0,1]. Default: the CI is not computed.

positive

A string with the name of the 'positive' level used as the reference level of 'response'. If left as the default empty string, the second factor level of 'response' is used.

parallel

If TRUE, the bootstrap method used to calculate the CI is processed in parallel, using the backend provided by plyr (foreach).

ncores

The number of nodes to be forked for the parallel computation of the CI. Default: the maximum available. None used if parallel = FALSE.

nboot

The number of bootstrap replicates to be used for the computation of the CI. Default: 2000.

plot

If TRUE, the DET curves are plotted. Default: FALSE.

...

Further attributes that will be passed to the plot function.

Value

A 'DETs' object. The object's 'detCurves' attribute contains one DET curve per classifier. Each DET curve is an object of class "DET", containing the DET curve parameters (false positive ratio, false negative ratio, and thresholds), along with the Equal Error Rate (EER). If the CI was calculated, the object also includes the median, upper, and lower CI limits for the false negative ratio and EER. Use the show method for more details about the results saved in a 'DETs' object.

Examples


library(DET)
n = 500
# Predictors with normal distribution
set.seed(1235)
scoreNegative1 = rnorm(n, mean = 0.25, sd = 0.125)
set.seed(5321)
scoreNegative2 = rnorm(n, mean = 0.25, sd = 0.125)
set.seed(11452)
scorePositive1 = rnorm(n, mean = 0.55, sd = 0.125)
set.seed(54321)
scorePositive2 = rnorm(n, mean = 0.65, sd = 0.125)
response = as.factor(c(rep(c("diseased"), times = n), rep(c("healthy"), times = n)))
predictor1 = c(scoreNegative1, scorePositive1)
predictor2 = c(scoreNegative2, scorePositive2)
predictors = matrix(c(predictor1, predictor2), ncol = 2)
colnames(predictors) = c("DET1", "DET2")
detCurves = detc(
  response,
  predictors,
  positive = "diseased",
  names = colnames(predictors)
)

# Run in parallel for faster execution by activating the logical argument
# 'parallel' and setting the number of cores of your computer
detCurvesWithConfidenceInterval = detc(
  response,
  predictors,
  positive = "diseased",
  names = colnames(predictors),
  conf = 0.95,
  parallel = TRUE,
  ncores = 2
)


DET documentation built on June 15, 2026, 9:08 a.m.

Related to detc in DET...