Description Usage Arguments Details Value Author(s) Examples
View source: R/adaptive_refinement_help.R
Calculates the weighted cross entropy / log-loss for a vector of observations and predicted probabilities (weighted by class proportions)
1 |
pred |
a numeric vector, the predicted probabilities of the reference class |
obs |
the vector of observations, a categorical variable with 2-4 levels |
sdpred |
either NULL or a vector containing the standard deviations of every estimate |
weighted |
a boolean, if FALSE, the unweighted logloss is calculated. By default, the weighted cross entropy is calculated. |
if sdpred contains the standard deviations for each estimated probability, then a lower bound of the log loss is returned.
a numeric value: cross entropy / log loss for comparison of classifiers. The smaller, the better.
Ann-Kristin Becker
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | #observations
obs<-as.factor(c("A","A","B"))
#correct prediction
pred1<-c(1,1,0)
#wrong prediction
pred2<-c(0,0,1)
cross.en(pred=pred1, obs=obs) #small
cross.en(pred=pred2, obs=obs) #large
#prediction of only majority class
pred3<-c(1,1,1)
#prediction of only minority class
pred4<-c(0,0,0)
cross.en(pred=pred3, obs=obs, weighted=TRUE)
cross.en(pred=pred4, obs=obs, weighted=TRUE)
#both equal (as weighted)
cross.en(pred=pred3, obs=obs, weighted=FALSE)
cross.en(pred=pred4, obs=obs, weighted=FALSE)
#unweighted, majority class is favored
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.