prob_to_binary: prob_to_binary

Description Usage Arguments Details Value Author(s) Examples

Description

This function transform probabilties to presence/absence, by assuming that the class with highest sample probability is present and the others classes are absent

Usage

1

Arguments

pred

a data.frame with class predictions n columns and m rows; each rows represents a sample, the columns represent the classes of outcomes.

Details

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.

Value

returns a list with the following elements:

Author(s)

Bob Douma

Examples

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

bobdouma/kappa_multinomial documentation built on May 12, 2019, 11:28 p.m.