dynConfMatrix {CustomerScoringMetrics} | R Documentation |
Calculate a confusion matrix
Description
Calculates a confusion matrix for real-valued classifier predictions, with the optional ability to dynamically determine an incidence-based cutoff value using validation sample predictions
Usage
dynConfMatrix(predTest, depTest, cutoff = 0.5, dyn.cutoff = FALSE,
predVal = NULL, depVal = NULL, returnClassPreds = FALSE)
Arguments
predTest |
Vector with predictions (real-valued or discrete) |
depTest |
Vector with real class labels |
cutoff |
Threshold for converting real-valued predictions into class predictions. Default 0.5. |
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. |
predVal |
Vector with predictions (real-valued or discrete). Only used if
|
depVal |
Optional vector with true class labels for validation data. Only used
if |
returnClassPreds |
Boolean value: should class predictions (using |
Value
A list with two elements:
confMatrix |
a confusion matrix |
cutoff |
the threshold value used to convert real-valued predictions to class predictions |
classPreds |
class predictions, if requested using |
Author(s)
Koen W. De Bock, kdebock@audencia.com
References
Witten, I.H., Frank, E. (2005): Data Mining: Practical Machine Learning Tools and Techniques, Second Edition. Chapter 5. Morgan Kauffman.
See Also
dynAccuracy
, confMatrixMetrics
Examples
## Load response modeling data set
data("response")
## Apply dynConfMatrix function to obtain a confusion matrix. Use validation sample
## predictions to dynamically determine an incidence-based cutoff value.
cm<-dynConfMatrix(response$test[,2],response$test[,1],dyn.cutoff=TRUE,
predVal=response$val[,2],depVal=response$val[,1])
print(cm)