auc_tidiers {broom} | R Documentation

## Tidiers for objects from the AUC package

### Description

Tidy "roc" objects from the "auc" package. This can be used to, for example, draw ROC curves in ggplot2.

### Usage

    ## S3 method for class 'roc'
    tidy(x, ...)

### Arguments

`x` | an "roc" object
`...` | Additional arguments, not used

### Value

A data frame with three columns:

`cutoff` | The cutoff of the prediction scores used for classification
`tpr` | The resulting true positive rate at that cutoff
`fpr` | The resulting false positive rate at that cutoff

If the labels had names, those are added as an "instance" column.

### Examples

    if (require("AUC", quietly = TRUE)) {
      data(churn)
      r <- roc(churn$predictions,churn$labels)

      td <- tidy(r)
      head(td)

      library(ggplot2)
      ggplot(td, aes(fpr, tpr)) +
        geom_line()

      # compare the ROC curves for two prediction algorithms
      library(dplyr)
      library(tidyr)

      rocs <- churn %>%
        tidyr::gather(algorithm, value, -labels) %>%
        group_by(algorithm) %>%
        do(tidy(roc(.$value, .$labels)))

      ggplot(rocs, aes(fpr, tpr, color = algorithm)) +
        geom_line()
    }

[Package broom version 0.4.1 Index]