data.frame-like objectR/as-ts-dataset.R
as_ts_dataset.RdCreate a torch dataset for time series data from a data.frame-like object
as_ts_dataset(
data,
formula,
index = NULL,
key = NULL,
predictors = NULL,
outcomes = NULL,
categorical = NULL,
timesteps,
horizon = 1,
sample_frac = 1,
scale = TRUE,
jump = 1,
...
)(data.frame) An input data.frame object with.
For now only single data frames are handled with no categorical features.
(formula) A formula describing, how to use the data
(character) The index column name.
(character) The key column name(s). Use only if formula was not specified.
(character) Input variable names. Use only if formula was not specified.
(character) Target variable names. Use only if formula was not specified.
(character) Categorical features.
(integer) The time series chunk length.
(integer) Forecast horizon.
(numeric) Sample a fraction of rows (default: 1, i.e.: all the rows).
(logical or list) Scale feature columns. Logical value or two-element list.
with values (mean, std)
If scale is TRUE, only the input variables are scale and not the outcome ones.
library(rsample)
library(dplyr, warn.conflicts = FALSE)
suwalki_temp <-
weather_pl %>%
filter(station == "SWK")
# Splitting on training and test
data_split <- initial_time_split(suwalki_temp)
train_ds <-
training(data_split) %>%
as_ts_dataset(tmax_daily ~ date + tmax_daily + rr_type,
timesteps = 20, horizon = 1)
#> Categorical variables found (1): rr_type
train_ds[1]
#> Error in torch_int(): could not find function "torch_int"