prob2categorical: Convert probabilities to categorical (factor)

View source: R/super_ops.R

prob2categoricalR Documentation

Convert probabilities to categorical (factor)

Description

Convert probabilities to categorical (factor)

Usage

prob2categorical(x, levels, binclasspos = NULL)

Arguments

x

Numeric vector: Probabilities

levels

Character vector: Class labels

binclasspos

Integer: Index of the positive class for binary classification

Value

Factor

Author(s)

EDG

Examples

## Not run: 
# Binary classification where "A" is the positive class, so .1 => B, .5 & .9 => A
prob2categorical(c(.1, .5, .9), c("A", "B"), 1)
# Binary classification where "B" is the positive class, so .1 => A, .5 & .9 => B
prob2categorical(c(.1, .5, .9), c("A", "B"), 2)
# Multi-class classification
prob <- matrix(c(.1, .3, .6, .05, .6, .35, .4, .3, .3), nrow = 3, byrow = TRUE)
prob2categorical(prob, c("A", "B", "C"))

## End(Not run)

egenn/rtemis documentation built on Dec. 17, 2024, 6:16 p.m.