ts_dataset: Create a time series dataset from a 'torch_tensor' matrix

ts_datasetR Documentation

Create a time series dataset from a torch_tensor matrix

Description

Create a time series dataset from a torch_tensor matrix

Usage

ts_dataset(
  data,
  timesteps,
  horizon,
  index,
  jump = horizon,
  past_spec = list(x = NULL),
  future_spec = list(y = NULL),
  categorical = NULL,
  sample_frac = 1,
  device = "cpu",
  extras = NULL,
  ...
)

Arguments

data

(data.frame) An data.frame-like input object.

timesteps

(integer) Number of timesteps for input tensor.

horizon

(integer) Forecast horizon: number of timesteps for output tensor.

jump

(integer) Jump length. By default: horizon length.

past_spec

(list) Specification of the variables which values from the past will be available. It should be a list with names representing names of tensors served by dataset, and values being feature indices.

future_spec

(list) Specification of the variableswith known values from the future. It should be a list with names representing names of tensors served b

categorical

(character) Names of specified column subsets considered as categorical. They will be provided as integer tensors.

extras

(list) List of extra object to be stored inside the ts_dataset object.

sample_fram

(numeric) A numeric value > 0. and <= 1 to sample a subset of data.

Note

If scale is TRUE, only the input variables are scale and not the outcome ones.

See: Is it necessary to scale the target value in addition to scaling features for regression analysis? (Cross Validated)

Examples

library(dplyr, warn.conflicts = FALSE)
library(torchts)

tarnow_temp <-
  weather_pl %>%
  filter(station == 'TRN') %>%
  arrange(date)

weather_pl_dataset <-
   ts_dataset(
     data = tarnow_temp,
     timesteps = 28,
     horizon = 7,
     past_spec = list(x_num = c('tmax_daily', 'tmin_daily')),
     future_spec   = list(y = 'tmax_daily')
   )

debugonce(weather_pl_dataset$.getitem)
weather_pl_dataset$.getitem(1)


krzjoa/torchts documentation built on June 24, 2022, 5:30 a.m.