Learn R Programming

WVPlots (version 1.1.1)

PRTPlot: Plot Precision-Recall or Enrichment-Recall as a function of threshold.

Description

Plot Precision-Recall or Enrichment-Recall as a function of threshold.

Usage

PRTPlot(frame, xvar, truthVar, truthTarget, title, ...,
  plotvars = c("precision", "recall"), thresholdrange = c(-Inf, Inf))

Arguments

frame

data frame to get values from

xvar

name of the independent (input or model) column in frame

truthVar

name of the dependent (output or result to be modeled) column in frame

truthTarget

value we consider to be positive

title

title to place on plot

...

no unnamed argument, added to force named binding of later arguments.

plotvars

variables to plot, must be at least one of "precision", "recall" and "enrichment". Defaults to c("precision", "recall")

thresholdrange

range of thresholds to plot.

Details

For a classifier, the precision is what fraction of predicted positives are true positives; the recall is what fraction of true positives the classifier finds, and the enrichment is the ratio of classifier precision to the average rate of positives. Plotting precision-recall or enrichment-recall as a function of classifier score helps identify a score threshold that achieves an acceptable tradeoff between precision and recall, or enrichment and recall.

See Also

PRPlot

Examples

Run this code
# NOT RUN {
set.seed(34903490)
x = rnorm(50)
y = 0.5*x^2 + 2*x + rnorm(length(x))
frm = data.frame(x=x,y=y,yC=y>=as.numeric(quantile(y,probs=0.8)))
frm$absY <- abs(frm$y)
frm$posY = frm$y > 0
frm$costX = 1
WVPlots::PRTPlot(frm, "x", "yC", TRUE, title="Example Precision-Recall threshold plot")

# }

Run the code above in your browser using DataLab