
Last chance! 50% off unlimited learning
Sale ends in
AutoDiffLagN create differences for selected numerical columns
AutoDiffLagN(
data,
DateVariable = NULL,
GroupVariables = NULL,
DiffVariables = NULL,
DiffDateVariables = NULL,
DiffGroupVariables = NULL,
NLag1 = 0L,
NLag2 = 1L,
Sort = FALSE,
RemoveNA = TRUE
)
Source data
Date column used for sorting
Difference data by group
Column names of numeric columns to difference
Columns names for date variables to difference. Output is a numeric value representing the difference in days.
Column names for categorical variables to difference. If no change then the output is 'No_Change' else 'New=NEWVAL Old=OLDVAL' where NEWVAL and OLDVAL are placeholders for the actual values
If the diff calc, we have column 1 - column 2. NLag1 is in reference to column 1. If you want to take the current value minus the previous weeks value, supply a zero. If you want to create a lag2 - lag4 NLag1 gets a 2.
If the diff calc, we have column 1 - column 2. NLag2 is in reference to column 2. If you want to take the current value minus the previous weeks value, supply a 1. If you want to create a lag2 - lag4 NLag1 gets a 4.
TRUE to sort your data inside the function
Set to TRUE to remove rows with NA generated by the lag operation
Other Feature Engineering:
AutoDataPartition()
,
AutoHierarchicalFourier()
,
AutoInteraction()
,
AutoLagRollStatsScoring()
,
AutoLagRollStats()
,
AutoTransformationCreate()
,
AutoTransformationScore()
,
AutoWord2VecModeler()
,
AutoWord2VecScoring()
,
CategoricalEncoding()
,
CreateCalendarVariables()
,
CreateHolidayVariables()
,
DummifyDT()
,
H2OAutoencoderScoring()
,
H2OAutoencoder()
,
ModelDataPrep()
,
TimeSeriesFill()
# NOT RUN {
# Create fake data
data <- RemixAutoML::FakeDataGenerator(
Correlation = 0.70,
N = 50000,
ID = 2L,
FactorCount = 3L,
AddDate = TRUE,
ZIP = 0L,
TimeSeries = FALSE,
ChainLadderData = FALSE,
Classification = FALSE,
MultiClass = FALSE)
# Store Cols to diff
Cols <- names(data)[which(unlist(data[, lapply(.SD, is.numeric)]))]
# Clean data before running AutoDiffLagN
data <- RemixAutoML::ModelDataPrep(data = data, Impute = FALSE, CharToFactor = FALSE, FactorToChar = TRUE)
# Run function
data <- RemixAutoML::AutoDiffLagN(
data,
DateVariable = "DateTime",
GroupVariables = c("Factor_1", "Factor_2"),
DiffVariables = Cols,
DiffDateVariables = NULL,
DiffGroupVariables = NULL,
NLag1 = 0L,
NLag2 = 1L,
Sort = TRUE,
RemoveNA = TRUE)
# }
# NOT RUN {
# }
Run the code above in your browser using DataLab