11.4 ROC Curves

  • ROC curves show the balance between sensitivity and specificity.
  • We’ll use the [ROCR] package. It only takes 3 commands:
    • calculate prediction() using the model
    • calculate the model performance() on both true positive rate and true negative rate for a whole range of cutoff values.
    • plot the curve.
      • The colorize option colors the curve according to the probability cutoff point.

We can also use the performance() function to evaluate the \(f1\) measure

We can dig into the perf.acc object to get the maximum accuracy value (y.value), then find the row where that value occurs, and link it to the corresponding cutoff value of x.

A cutoff of 0.42 provides the maximum accuracy measure.

You can do the same process with other measures of optimization such as the \(f1\) score.

ROC curves: