partition: Subset data set/time series into several slices

View source: R/deepTimeSeries.r

partitionR Documentation

Subset data set/time series into several slices

Description

Subset data set/time series into several slices

Usage

partition(
  dataset,
  column = NULL,
  between = NULL,
  proportion = 0.7,
  shuffle = FALSE
)

Arguments

dataset

A data set or time series, usually a data frame.

column

The name or index of a periodic column.

between

A list of usually value pairs which are used as lower and upper boundaries for the slices of dataset.

proportion

A proportion value, default 0.7, of the percentage amount of rows of the first subset, usually the training set. The remaining rows build the second subset, usually the test set.

shuffle

A logical value indicating whether the rows of the subsets should be shuffled, default FALSE. For a time series this argument is ignored because of the inherent chronological order.

Details

If no column and between values are specified a typically split into two slices is done.

Value

Subsets of dataset usually for training and test purposes for Machine and Deep Learning tasks.

See Also

Other Time Series: diff_log(), diff_percentage(), diffinv_log(), diffinv_percentage(), diffinv_simple(), get_season(), invert_differencing(), lags(), period(), stationary()

Examples

df <- data.frame(date = as.Date(c("01.01.2021", "02.01.2021", "03.01.2021", "04.01.2021", "05.01.2021", "06.01.2021", "07.01.2021", "08.01.2021", "09.01.2021", "10.01.2021", "11.01.2021", "12.01.2021", "13.01.2021", "14.01.2021"), format = "%d.%m.%Y"),
                 value = sample(100, 14L))
library(keras)
c(train, test) %<-% partition(df, shuffle = T)
c(train, test1, test2, test3) %<-%
  partition(df, column = "date",
                between = list(c(from = "2021-01-01", to = "2021-01-06"),
                               c(from = "2021-01-07", to = "2021-01-10"),
                               c(from = "2021-01-08", to = "2021-01-11"),
                               c(from = "2021-01-01")))


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