Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

decodeClassLabels

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

Neural Networks using the Stuttgart Neural Network Simulator (SNNS)

v0.4-12
LGPL (>= 2) | file LICENSE
Authors
Christoph Bergmeir [aut, cre, cph], José M. Benítez [ths], Andreas Zell [ctb] (Part of original SNNS development team), Niels Mache [ctb] (Part of original SNNS development team), Günter Mamier [ctb] (Part of original SNNS development team), Michael Vogt [ctb] (Part of original SNNS development team), Sven Döring [ctb] (Part of original SNNS development team), Ralf Hübner [ctb] (Part of original SNNS development team), Kai-Uwe Herrmann [ctb] (Part of original SNNS development team), Tobias Soyez [ctb] (Part of original SNNS development team), Michael Schmalzl [ctb] (Part of original SNNS development team), Tilman Sommer [ctb] (Part of original SNNS development team), Artemis Hatzigeorgiou [ctb] (Part of original SNNS development team), Dietmar Posselt [ctb] (Part of original SNNS development team), Tobias Schreiner [ctb] (Part of original SNNS development team), Bernward Kett [ctb] (Part of original SNNS development team), Martin Reczko [ctb] (Part of original SNNS external contributors), Martin Riedmiller [ctb] (Part of original SNNS external contributors), Mark Seemann [ctb] (Part of original SNNS external contributors), Marcus Ritt [ctb] (Part of original SNNS external contributors), Jamie DeCoster [ctb] (Part of original SNNS external contributors), Jochen Biedermann [ctb] (Part of original SNNS external contributors), Joachim Danz [ctb] (Part of original SNNS development team), Christian Wehrfritz [ctb] (Part of original SNNS development team), Patrick Kursawe [ctb] (Contributors to SNNS Version 4.3), Andre El-Ama [ctb] (Contributors to SNNS Version 4.3)
Initial release
2019-09-16

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.