Learn R Programming

RemixAutoML (version 0.11.0)

DT_GDL_Feature_Engineering: An Automated Feature Engineering Function Using data.table frollmean

Description

Builds autoregressive and moving average from target columns and distributed lags and distributed moving average for independent features distributed across time. On top of that, you can also create time between instances along with their associated lags and moving averages. This function works for data with groups and without groups.

Usage

DT_GDL_Feature_Engineering(data, lags = c(seq(1, 50, 1)),
  periods = c(seq(5, 95, 5)), statsNames = c("MA"),
  targets = c("qty"), groupingVars = c("Group1", "Group2"),
  sortDateName = c("date"), timeDiffTarget = c("TimeDiffName"),
  timeAgg = c("days"), WindowingLag = 0, Type = c("Lag"),
  SimpleImpute = TRUE)

Arguments

data

A data.table you want to run the function on

lags

A numeric vector of the specific lags you want to have generated. You must include 1 if WindowingLag = 1.

periods

A numeric vector of the specific rolling statistics window sizes you want to utilize in the calculations.

statsNames

A character vector of the corresponding names to create for the rollings stats variables.

targets

A character vector of the column names for the reference column in which you will build your lags and rolling stats

groupingVars

A character vector of categorical variable names you will build your lags and rolling stats by

sortDateName

The column name of your date column used to sort events over time

timeDiffTarget

Specify a desired name for features created for time between events. Set to NULL if you don't want time between events features created.

timeAgg

List the time aggregation level for the time between events features, such as "hour", "day", "week", "month", "quarter", or "year"

WindowingLag

Set to 0 to build rolling stats off of target columns directly or set to 1 to build the rolling stats off of the lag-1 target

Type

List either "Lag" if you want features built on historical values or "Lead" if you want features built on future values

SimpleImpute

Set to TRUE for factor level imputation of "0" and numeric imputation of -1

Value

data.table of original data plus created lags, rolling stats, and time between event lags and rolling stats

See Also

Other Feature Engineering: AutoDataPartition, AutoTransformationCreate, AutoTransformationScore, AutoWord2VecModeler, CreateCalendarVariables, CreateHolidayVariables, DummifyDT, GDL_Feature_Engineering, ModelDataPrep, Partial_DT_GDL_Feature_Engineering, Scoring_GDL_Feature_Engineering, TimeSeriesFill

Examples

Run this code
# NOT RUN {
N = 25116
data <- data.table::data.table(DateTime = as.Date(Sys.time()),
                               Target = stats::filter(rnorm(N,
                                                            mean = 50,
                                                            sd = 20),
                                                      filter=rep(1,10),
                                                      circular=TRUE))
data[, temp := seq(1:N)][, DateTime := DateTime - temp][, temp := NULL]
data <- data[order(DateTime)]
data <- DT_GDL_Feature_Engineering(data,
                                   lags           = c(seq(1,5,1)),
                                   periods        = c(3,5,10,15,20,25),
                                   statsNames     = c("MA"),
                                   targets        = c("Target"),
                                   groupingVars   = NULL,
                                   sortDateName   = "DateTime",
                                   timeDiffTarget = c("Time_Gap"),
                                   timeAgg        = c("days"),
                                   WindowingLag   = 1,
                                   Type           = "Lag",
                                   SimpleImpute   = TRUE)
# }

Run the code above in your browser using DataLab