get_LSTM_XY: Extract features (X) and outcome (Y) vector or matrix from...

View source: R/deepRNN.r

get_LSTM_XYR Documentation

Extract features (X) and outcome (Y) vector or matrix from data/time series in LSTM preformat

Description

get_LSTM_XY extracts features and outcomes from a data/time series in a Long Short-Term Memory (LSTM) compatible preformat. Within a univariate time series, y(t) is explained by past y(t-1), y(t-2) etc. Therefore the last sample of the feature set must be deleted, because there is no Y-value for it. Resampling of the Y-values must start at timesteps + 1. That is different to a multivariate time series. For y(t), the corresponding features at time t are already given. Resampling must start at timesteps.

Usage

get_LSTM_XY(
  dataset,
  x = NULL,
  y = 2L,
  other_columns = NULL,
  timesteps = 1L,
  xlag = 0L,
  y_as_feature = c("none", "plain", "timesteps"),
  ylag = 0L
)

Arguments

dataset

A data set, usually a matrix or data frame.

x

The names or indices of the feature columns.

y

The names or indices of the outcome columns.

other_columns

The names or indices of further columns, e.g. a periodic column.

timesteps

A number or vector of timesteps for x and y. A timestep denotes the number of different periods of the values within one sample. A feature does always have at least one timestep, but an outcome is either a scalar with one implicit timestep or a sequence with at least two timesteps. If only one value is given, this value is used for the resampled feature tensor produced by as_LSTM_X. In this case, y will be treated as a scalar outcome. If two values are given, the first value is used as before and the second value is the number of timesteps for the resampled sequence or multi-step outcome produced by as_LSTM_Y.

xlag

The considered lags on feature side. For a univariate time series at least a lag of 1 is needed. For a multivariate time series no lag must be necessarily used. This argument can also be a vector of the same length as x. In that case, each feature can have its own specified lag.

y_as_feature

Indicates whether lagged outcomes are used as features in a multivariate time series.
none doesn't include lagged y-variables (default).
plain The lagged y-variables retrieve in the periods (timesteps) of the later resampled feature matrix thru as_LSTM_X. Therefore, only one lagged y-variable with a lag order of adjusted y_as_feature_lag is chosen.
timesteps The number of included lagged y-variables is equal to the value of the timesteps argument.

ylag

The considered lag for lagged outcomes (y) as further features.

Value

A list with named elements X: A feature matrix in LSTM compatible preformat for usage with as_LSTM_X.
Y: An outcome matrix in LSTM compatible preformat for usage with as_LSTM_Y.
other_columns: A data frame of the selected other_columns.

See Also

as_LSTM_X, as_LSTM_Y.

Other Recurrent Neural Network (RNN): as_LSTM_X(), as_LSTM_Y(), as_LSTM_data_frame(), as_LSTM_period_outcome(), as_lag(), as_timesteps(), build_LSTM(), fit_LSTM(), get_period_shift(), load_weights_ANN(), predict_ANN(), save_weights_ANN(), start_invert_differencing()


stschn/deepANN documentation built on June 25, 2024, 7:27 a.m.