Learn R Programming

precrec (version 0.24.0)

as.data.table: Convert a curves and points object to a data.table

Description

The as.data.table function converts an S3 object generated by evalmod() to a data.table. It is the counterpart of as.data.frame(), for callers who would rather have the data.table that precrec builds internally than a copy of it as a plain data frame.

Usage

# S3 method for sscurves
as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for mscurves as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for smcurves as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for mmcurves as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for sspoints as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for mspoints as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for smpoints as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for mmpoints as.data.table(x, keep.rownames = FALSE, raw_curves = NULL, ...)

# S3 method for aucroc as.data.table(x, keep.rownames = FALSE, ...)

Value

The as.data.table function returns a data.table with the same columns as as.data.frame() returns for the same object.

Arguments

x

An S3 object generated by evalmod(). The as.data.table function accepts the same objects as as.data.frame().

keep.rownames

Ignored. Present because data.table::as.data.table has it in its signature; the objects this method converts carry no row names.

raw_curves

A Boolean value to specify whether raw curves are shown instead of the average curve. It is effective only when raw_curves is set to TRUE of the evalmod() function.

...

Not used by this method.

See Also

evalmod() for generating S3 objects with performance evaluation metrics. as.data.frame() for the plain data frame equivalent. fortify() for converting the same objects for ggplot2.

Examples

Run this code

## Load a dataset with 10 positives and 10 negatives
data(P10N10)

## Generate an sscurve object that contains ROC and Precision-Recall curves
sscurves <- evalmod(scores = P10N10$scores, labels = P10N10$labels)

## Convert sscurves to a data.table
if (requireNamespace("data.table", quietly = TRUE)) {
  head(data.table::as.data.table(sscurves))
}

Run the code above in your browser using DataLab