SoftRandomForest (version 0.1.0)

SoftClassMatrix: Converting response vector to sparse matrix.

Description

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

Usage

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.

Value

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

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.

Examples

Run this code
# NOT RUN {
Input = c("A", "C", "B", "B", "A", "B")
SoftClassMatrix(Input, classes = c("A", "B", "C", "D"))
# }

Run the code above in your browser using DataLab