A predx class for binned probabilistic predictions with categorical bins specified by strings.

BinCat(x)

is.BinCat(x)

# S4 method for BinCat
predx_to_json(x)

# S4 method for BinCat
as.data.frame(x, row.names = NULL, optional = FALSE, ...)

# S4 method for BinCat
transform_predx(x, to_class, ...)

Details

BinCat is flexible as it can be used for any binned predictions. Individual probabilities (prob) must be greater than or equal to 0 and less than or equal to 1 and the vector of probabilities must sum to 1.

In JSON and CSV representations, the bins are named cat and the probabilities are named prob.

Slots

predx

A data.frame with two columns: cat (character) and prob (numeric).

Examples

x <- BinCat(data.frame( cat = c('a', 'b', 'c'), prob = c(0, 0.3, 0.7) )) x
#> An object of class "BinCat" #> Slot "predx": #> cat prob #> 1 a 0.0 #> 2 b 0.3 #> 3 c 0.7 #>
# create predx dataframe x_df <- as.predx_df(list( location = c('Mercury', 'Venus', 'Earth'), target = 'habitability', predx = list(x, x) ))
#> Error: Tibble columns must have consistent lengths, only values of length one are recycled: #> * Length 2: Column `predx` #> * Length 3: Column `location`