decodeClassLabels: Decode class labels to a binary matrix

View source: R/reg_class.R

decodeClassLabelsR Documentation

Decode class labels to a binary matrix

Description

This method decodes class labels from a numerical or levels vector to a binary matrix, i.e., it converts the input vector to a binary matrix.

Usage

decodeClassLabels(x, valTrue = 1, valFalse = 0)

Arguments

x

class label vector

valTrue

see Details paragraph

valFalse

see Details paragraph

Details

In the matrix, the value valTrue (e.g. 1) is present exactly in the column given by the value in the input vector, and the value valFalse (e.g. 0) in the other columns. The number of columns of the resulting matrix depends on the number of unique labels found in the vector. E.g. the input c(1, 3, 2, 3) will result in an output matrix with rows: 100 001 010 001

Value

a matrix containing the decoded class labels

Author(s)

The implementation is a slightly modified version of the function class.ind from the nnet package of Brian Ripley.

References

Venables, W. N. and Ripley, B. D. (2002), 'Modern Applied Statistics with S', Springer-Verlag.

Examples

decodeClassLabels(c(1,3,2,3))
decodeClassLabels(c("r","b","b","r", "g", "g"))

data(iris)
decodeClassLabels(iris[,5])

RSNNS documentation built on May 29, 2024, 4:37 a.m.