SoftClassMatrix: Converting response vector to sparse matrix.

Description Usage Arguments Details Value Examples

Description

SoftClassMatrix converts a classification response matrix into a sparse matrix that can be used for inputs into the SoftRandomForest function.

Usage

1
SoftClassMatrix(responses, classes = NA)

Arguments

responses

A vector of classification responses.

classes

A vector of possible classifications with a manually specified order. Must contain all elements in the responses vector.

Details

SoftClassMatrix runs through each line of a classification vector and creates a sparse matrix where each column represents an individual classification. The output matrix has number of rows equal to the number of rows of the input vector and number of columns equal to the number of unique entries in the input vector. The order is determined by the order they appear in the vector. Adjust this afterwards if another order is desired.

Value

A matrix where 1 indicates that observation was classified as that column's response and 0 if not.

Examples

1
2
Input = c("A", "C", "B", "B", "A", "B")
SoftClassMatrix(Input, classes = c("A", "B", "C", "D"))

SoftRandomForest documentation built on May 15, 2019, 5:05 p.m.