Learn R Programming

precrec (version 0.24.0)

print: Print the summary of a precrec object

Description

The print function prints a summary of an S3 object created by mmdata(), evalmod(), metric_curve() or classification_report(). It is called for its side effect, and is what the console shows when one of those objects is evaluated at the prompt.

Usage

# S3 method for mdat
print(x, ...)

# S3 method for curve_info print(x, ...)

# S3 method for beval_info print(x, ...)

# S3 method for aucroc print(x, ...)

# S3 method for xycurve_info print(x, ...)

# S3 method for classification_report print(x, digits = 2, ...)

Value

The print function returns x invisibly.

Arguments

x

An S3 object created by mmdata(), evalmod(), metric_curve() or classification_report(). The print function takes one of the following S3 objects.

S3 objectCreated by
mdatmmdata()
curve_infoevalmod()
beval_infoevalmod(mode = "basic")
aucrocevalmod(mode = "aucroc")
xycurve_infometric_curve()
classification_reportclassification_report()

Every object but a classification_report includes a summary of the input data - the model names, the dataset IDs and the class counts. Alongside it, a curve object reports its AUCs beside the baseline each one is read against - 0.5 for a ROC curve and the proportion of positives for a precision-recall curve, see auc() - and its partial AUCs as well when it came from part(); a basic-metric object reports what each metric abbreviation means and a five-number summary of every metric; an aucroc object reports the AUCs beside the U statistics they came from; and a metric_curve() object names the metric pair and counts the points on it. A classification_report prints its own table of per-class precision, recall and F-score.

The curve and point objects carry a second class naming how many models and test datasets they hold, such as sscurves or mmpoints, but all of them print through curve_info or beval_info. See the Value section of evalmod().

...

Not used by these methods.

digits

The number of digits after the decimal point, between 0 and 20. Used by the classification_report method only.

See Also

evalmod() and mmdata() for creating the objects, as.data.frame() for the same results as a data frame, and auc() for the AUCs alone.

Examples

Run this code

##################################################
### Input data
###

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

mdat <- mmdata(P10N10$scores, P10N10$labels)
mdat


##################################################
### ROC and Precision-Recall curves
###

curves <- evalmod(mdat)
curves

## Partial curves also report the partial AUCs
part(curves, xlim = c(0, 0.25))


##################################################
### Basic evaluation metrics
###

points <- evalmod(mdat, mode = "basic")
points


##################################################
### AUC with the U statistic
###

evalmod(mdat, mode = "aucroc")


##################################################
### One metric against another
###

metric_curve(mdat)


##################################################
### Per-class precision, recall and F-score
###

classification_report(mdat, at = 12)

Run the code above in your browser using DataLab