loss_functions {xnet} | R Documentation |
loss functions
Description
These functions can be used as loss functions in tune
.
Currently, two functions are provided: a function calculating the
classic mean squared error (loss_mse
) and a function
calculating 1 - AUC (loss_auc
).
Usage
loss_mse(Y, LOO, na.rm = FALSE)
loss_auc(Y, LOO)
Arguments
Y |
the label matrix with observed responses |
LOO |
the leave-one-out crossvalidation (or predictions if you
must). This one can be calculated by the function |
na.rm |
a logical value |
Details
The AUC is calculated by sorting the Y
matrix based on
the order of the values in the LOO
matrix. The false and true
positive rates are calculated solely based on that ordering, which
allows for values in LOO
outside the range [0,1]. It's
a naive implementation which is good enough for tuning, but
shouldn't be used as a correct value for 1 - auc in case the
values in LOO
are outside the range [0,1].
Note
The function loss_auc
should only be used for a Y
matrix that contains solely the values 0 and 1.
See Also
tune
for application of the loss function
Examples
x <- c(1,0,0,1,0,0,1,0,1)
y <- c(0.8,-0.1,0.2,0.2,0.4,0.01,1.12,0.9,0.9)
loss_mse(x,y)
loss_auc(x,y)