DMwR (version 0.4.1)

PRcurve: Plot a Precision/Recall curve

Description

Precision/recall (PR) curves are visual representations of the performance of a classification model in terms of the precision and recall statistics. The curves are obtained by proper interpolation of the values of the statistics at different working points. These working points can be given by different cut-off limits on a ranking of the class of interest provided by the model.

Usage

PRcurve(preds, trues, ...)

Arguments

preds
A vector containing the predictions of the model.
trues
A vector containing the true values of the class label. Must have the same dimension as preds.
...
Further parameters that are passed to the plot() function.

Details

This function uses the infra-structure provided by the ROCR package (Sing et al., 2009). This package allows us to obtain several measures of the predictive performance of models. We use it to obtain the precision and recall of the predictions of a model. We then calculate the interpolated precision to avoid the saw-tooth effect that we would get with the standard plots produced by the ROCR package. The interpolated precision for a value r of recall is the the highest precision value for any recall level greather or equal to r.

References

Sing, T., Sander, O., Beerenwinkel, N., and Lengauer, T. (2009). ROCR: Visualizing the performance of scoring classifiers. R package version 1.0-4.

Torgo, L. (2010) Data Mining using R: learning with case studies, CRC Press (ISBN: 9781439810187).

http://www.dcc.fc.up.pt/~ltorgo/DataMiningWithR

See Also

prediction, performance, CRchart

Examples

Run this code
## A simple example with data in package ROCR
library(ROCR)
data(ROCR.simple)
pred <- prediction(ROCR.simple$predictions,ROCR.simple$labels)
perf <- performance(pred,"prec","rec")
## The plot obtained with the standard ROCR functions
## Not run: 
# plot(perf)
# ## End(Not run)

## Now our Precision/Recall curve avoiding the saw-tooth effect
## Not run: 
# PRcurve(ROCR.simple$predictions,ROCR.simple$labels)
# ## End(Not run)

Run the code above in your browser using DataLab