dynAccuracy: Calculate accuracy

Description Usage Arguments Value Author(s) See Also Examples

View source: R/dynAccuracy.R

Description

Calculates accuracy (percentage correctly classified instances) for real-valued classifier predictions, with the optional ability to dynamically determine an incidence-based cutoff value using validation sample predictions

Usage

1
2
dynAccuracy(predTest, depTest, dyn.cutoff = FALSE, cutoff = 0.5,
  predVal = NULL, depVal = NULL)

Arguments

predTest

Vector with predictions (real-valued or discrete)

depTest

Vector with real class labels

dyn.cutoff

Logical indicator to enable dynamic threshold determination using validation sample predictions. In this case, the function determines, using validation data, the indidicence (occurrence percentage of the customer behavior or characterstic of interest) and chooses a cutoff value so that the number of predicted positives is equal to the number of true positives. If TRUE, then the value for the cutoff parameter is ignored.

cutoff

Threshold for converting real-valued predictions into class predictions. Default 0.5.

predVal

Vector with predictions (real-valued or discrete). Only used if dyn.cutoff is TRUE.

depVal

Optional vector with true class labels for validation data. Only used if dyn.cutoff is TRUE.

Value

Accuracy value

accuracy

accuracy value

cutoff

the threshold value used to convert real-valued predictions to class predictions

Author(s)

Koen W. De Bock, kdebock@audencia.com

See Also

dynConfMatrix,confMatrixMetrics

Examples

1
2
3
4
5
6
7
## Load response modeling data set
data("response")
## Apply dynAccuracy function to obtain the accuracy that is achieved on the test sample.
## Use validation sample predictions to dynamically determine a cutoff value.
acc<-dynAccuracy(response$test[,2],response$test[,1],dyn.cutoff=TRUE,predVal=
response$val[,2],depVal=response$val[,1])
print(acc)

CustomerScoringMetrics documentation built on May 2, 2019, 5:17 a.m.