Skip to contents

Calculate all measures for sparse ROC

Usage

getThresholdSummary(
  prediction,
  predictionType = "binary",
  typeColumn = "evaluation"
)

Arguments

prediction

A prediction object

predictionType

The type of prediction (binary or survival)

typeColumn

A column that is used to stratify the results

Value

A data.frame with TP, FP, TN, FN, TPR, FPR, accuracy, PPF, FOR and Fmeasure

Details

Calculates the TP, FP, TN, FN, TPR, FPR, accuracy, PPF, FOR and Fmeasure from a prediction object

Examples

prediction <- data.frame(rowId = 1:100, 
                         outcomeCount = stats::rbinom(1:100, 1, prob=0.5),
                         value = runif(100), 
                         evaluation = rep("Train", 100))
summary <- getThresholdSummary(prediction)
str(summary)
#> 'data.frame':	100 obs. of  24 variables:
#>  $ evaluation             : chr  "Train" "Train" "Train" "Train" ...
#>  $ predictionThreshold    : num  0.992 0.971 0.963 0.958 0.952 ...
#>  $ preferenceThreshold    : num  0.993 0.974 0.967 0.963 0.957 ...
#>  $ positiveCount          : num  1 2 3 4 5 6 7 8 9 10 ...
#>  $ negativeCount          : num  99 98 97 96 95 94 93 92 91 90 ...
#>  $ trueCount              : num  47 47 47 47 47 47 47 47 47 47 ...
#>  $ falseCount             : num  53 53 53 53 53 53 53 53 53 53 ...
#>  $ truePositiveCount      : num  1 1 1 1 1 1 1 2 3 3 ...
#>  $ trueNegativeCount      : num  53 52 51 50 49 48 47 47 47 46 ...
#>  $ falsePositiveCount     : num  0 1 2 3 4 5 6 6 6 7 ...
#>  $ falseNegativeCount     : num  46 46 46 46 46 46 46 45 44 44 ...
#>  $ f1Score                : num  0.0417 0.0408 0.04 0.0392 0.0385 ...
#>  $ accuracy               : num  0.54 0.53 0.52 0.51 0.5 0.49 0.48 0.49 0.5 0.49 ...
#>  $ sensitivity            : num  0.0213 0.0213 0.0213 0.0213 0.0213 ...
#>  $ falseNegativeRate      : num  0.979 0.979 0.979 0.979 0.979 ...
#>  $ falsePositiveRate      : num  0 0.0189 0.0377 0.0566 0.0755 ...
#>  $ specificity            : num  1 0.981 0.962 0.943 0.925 ...
#>  $ positivePredictiveValue: num  1 0.5 0.333 0.25 0.2 ...
#>  $ falseDiscoveryRate     : num  0 0.5 0.667 0.75 0.8 ...
#>  $ negativePredictiveValue: num  0.535 0.531 0.526 0.521 0.516 ...
#>  $ falseOmissionRate      : num  0.465 0.469 0.474 0.479 0.484 ...
#>  $ positiveLikelihoodRatio: num  Inf 1.128 0.564 0.376 0.282 ...
#>  $ negativeLikelihoodRatio: num  0.979 0.998 1.017 1.037 1.059 ...
#>  $ diagnosticOddsRatio    : num  Inf 1.13 0.554 0.362 0.266 ...