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.997 0.995 0.988 0.986 0.975 ...
#>  $ preferenceThreshold    : num  0.996 0.993 0.985 0.982 0.968 ...
#>  $ 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  56 56 56 56 56 56 56 56 56 56 ...
#>  $ falseCount             : num  44 44 44 44 44 44 44 44 44 44 ...
#>  $ truePositiveCount      : num  0 0 1 2 3 3 4 5 5 6 ...
#>  $ trueNegativeCount      : num  43 42 42 42 42 41 41 41 40 40 ...
#>  $ falsePositiveCount     : num  1 2 2 2 2 3 3 3 4 4 ...
#>  $ falseNegativeCount     : num  56 56 55 54 53 53 52 51 51 50 ...
#>  $ f1Score                : num  NaN NaN 0.0339 0.0667 0.0984 ...
#>  $ accuracy               : num  0.43 0.42 0.43 0.44 0.45 0.44 0.45 0.46 0.45 0.46 ...
#>  $ sensitivity            : num  0 0 0.0179 0.0357 0.0536 ...
#>  $ falseNegativeRate      : num  1 1 0.982 0.964 0.946 ...
#>  $ falsePositiveRate      : num  0.0227 0.0455 0.0455 0.0455 0.0455 ...
#>  $ specificity            : num  0.977 0.955 0.955 0.955 0.955 ...
#>  $ positivePredictiveValue: num  0 0 0.333 0.5 0.6 ...
#>  $ falseDiscoveryRate     : num  1 1 0.667 0.5 0.4 ...
#>  $ negativePredictiveValue: num  0.434 0.429 0.433 0.438 0.442 ...
#>  $ falseOmissionRate      : num  0.566 0.571 0.567 0.562 0.558 ...
#>  $ positiveLikelihoodRatio: num  0 0 0.393 0.786 1.179 ...
#>  $ negativeLikelihoodRatio: num  1.023 1.048 1.029 1.01 0.991 ...
#>  $ diagnosticOddsRatio    : num  0 0 0.382 0.778 1.189 ...