Description Usage Arguments Details Value Author(s) Examples
This function transform probabilties to presence/absence, by assuming that the class with highest sample probability is present and the others classes are absent
1 | prob_to_binary(pred)
|
pred |
a data.frame with class predictions n columns and m rows; each rows represents a sample, the columns represent the classes of outcomes. |
helper function for the tutorial. This function tansforms probabilities to presence/absence, but assuming that the class that occurs with highest probability is present (1), and the others are absent (0). If multiple classes are predicted with the same maximum probability one class is chosen randomly.
returns a list with the following elements:
pred
Bob Douma
1 2 3 4 5 | # generate multinomial probabilties with four classes
pred <- gtools::rdirichlet(100, c(0.1,0.1,0.5,0.5))
pred_discrete <- prob_to_binary(pred)
obs <- t(apply(pred,1,rmultinom,size=1,n=1)) # generate multinomial observations with four classes
multinomialperform::kappa_multinomial(obs=obs,pred=pred_discrete) # calculate kappa multinomial
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.