preprocess_one_hot_encoding: One Hot Encoding

View source: R/preprocess_one_hot_encoding.R

preprocess_one_hot_encodingR Documentation

One Hot Encoding

Description

A utility to do one-hot encoding on features of dataset.

Usage

preprocess_one_hot_encoding(
  input,
  dimensions = NA,
  verbose = getOption("mlpack.verbose", FALSE)
)

Arguments

input

Matrix containing data (numeric matrix/data.frame with info).

dimensions

Index of dimensions that need to be one-hot encoded (if unspecified, all categorical dimensions are one-hot encoded) (integer vector).

verbose

Display informational messages and the full list of parameters and timers at the end of execution. Default value "getOption("mlpack.verbose", FALSE)" (logical).

Details

This utility takes a dataset and a vector of indices and does one-hot encoding of the respective features at those indices. Indices represent the IDs of the dimensions to be one-hot encoded.

If no dimensions are specified with "dimensions", then all categorical-type dimensions will be one-hot encoded. Otherwise, only the dimensions given in "dimensions" will be one-hot encoded.

The output matrix with encoded features may be saved with the "output" parameters.

Value

A list with several components:

output

Matrix to save one-hot encoded features data to (numeric matrix).

Author(s)

mlpack developers

Examples

# So, a simple example where we want to encode 1st and 3rd feature from
# dataset "X" into "X_output" would be

## Not run: 
output <- preprocess_one_hot_encoding(input=X, dimensions=1, dimensions=3)
X_ouput <- output$output

## End(Not run)

mlpack documentation built on June 22, 2024, 9:36 a.m.