matrix_to_dataset: Convert data to torch format

View source: R/convert_data.R

matrix_to_datasetR Documentation

Convert data to torch format

Description

For an x/y interface, matrix_to_dataset() converts the data to proper encodings then formats the results for consumption by torch.

Usage

matrix_to_dataset(x, y)

Arguments

x

A numeric matrix of predictors.

y

A vector. If regression than y is numeric. For classification, it is a factor.

Details

Missing values should be removed before passing data to this function.

Value

An R6 index sampler object with classes "training_set", "dataset", and "R6".

Examples

if (torch::torch_is_installed()) {
  matrix_to_dataset(as.matrix(mtcars[, -1]), mtcars$mpg)
}

tidymodels/lantern documentation built on Feb. 28, 2024, 12:59 a.m.