confusion {softclassval} | R Documentation |
Performance calculation for soft classification
Description
These performance measures can be used with prediction and reference being continuous class memberships in [0, 1].
Calculate the soft confusion matrix
Usage
confusion(r = stop("missing reference"), p = stop("missing prediction"),
groups = NULL, operator = "prd", drop = FALSE, .checked = FALSE)
confmat(r = stop("missing reference"), p = stop("missing prediction"), ...)
sens(r = stop("missing reference"), p = stop("missing prediction"),
groups = NULL, operator = "prd", op.dev = dev(match.fun(operator)),
op.postproc = postproc(match.fun(operator)), eps = 1e-08, drop = FALSE,
.checked = FALSE)
spec(r = stop("missing reference"), p = stop("missing prediction"), ...)
ppv(r = stop("missing reference"), p = stop("missing prediction"), ...,
.checked = FALSE)
npv(r = stop("missing reference"), p = stop("missing prediction"), ...,
.checked = FALSE)
Arguments
r |
vector, matrix, or array with reference. |
p |
vector, matrix, or array with predictions |
groups |
grouping variable for the averaging by |
operator |
the |
drop |
should the results possibly be returned as vector instead of 1d array? (Note that
levels of |
.checked |
for internal use: the inputs are guaranteed to be of same size and shape. If
|
... |
handed to |
op.dev |
does the operator measure deviation? |
op.postproc |
if a post-processing function is needed after averaging, it can be given here. See the example. |
eps |
limit below which denominator is considered 0 |
Details
The rows of r
and p
are considered the samples, columns will usually hold the
classes, and further dimensions are preserved but ignored.
r
must have the same number of rows and columns as p
, all other dimensions may be
filled by recycling.
spec
, ppv
, and npv
use the symmetry between the performance measures as
described in the article and call sens
.
Value
numeric of size (ngroups x dim (p) [-1]
) with the respective performance measure
Author(s)
Claudia Beleites
References
see the literature in citation ("softclassval")
See Also
Operators: prd
For the complete confusion matrix, confmat
Examples
ref <- softclassval:::ref
ref
pred <- softclassval:::pred
pred
## Single elements or diagonal of confusion matrix
confusion (r = ref, p = pred)
## complete confusion matrix
cm <- confmat (r = softclassval:::ref, p = pred) [1,,]
cm
## Sensitivity-Specificity matrix:
cm / rowSums (cm)
## Matrix with predictive values:
cm / rep (colSums (cm), each = nrow (cm))
## sensitivities
sens (r = ref, p = pred)
## specificities
spec (r = ref, p = pred)
## predictive values
ppv (r = ref, p = pred)
npv (r = ref, p = pred)