AutoH2OCARMA | R Documentation |
AutoH2OCARMA Mutlivariate Forecasting with calendar variables, Holiday counts, holiday lags, holiday moving averages, differencing, transformations, interaction-based categorical encoding using target variable and features to generate various time-based aggregated lags, moving averages, moving standard deviations, moving skewness, moving kurtosis, moving quantiles, parallelized interaction-based fourier pairs by grouping variables, and Trend Variables.
AutoH2OCARMA(
AlgoType = "drf",
ExcludeAlgos = "XGBoost",
data,
TrainOnFull = FALSE,
TargetColumnName = "Target",
PDFOutputPath = NULL,
SaveDataPath = NULL,
TimeWeights = NULL,
NonNegativePred = FALSE,
RoundPreds = FALSE,
DateColumnName = "DateTime",
GroupVariables = NULL,
HierarchGroups = NULL,
TimeUnit = "week",
TimeGroups = c("weeks", "months"),
FC_Periods = 30,
PartitionType = "timeseries",
MaxMem = {
gc()
paste0(as.character(floor(as.numeric(system("awk '/MemFree/ {print $2}' /proc/meminfo",
intern = TRUE))/1e+06)), "G")
},
NThreads = max(1, parallel::detectCores() - 2),
Timer = TRUE,
DebugMode = FALSE,
TargetTransformation = FALSE,
Methods = c("YeoJohnson", "BoxCox", "Asinh", "Log", "LogPlus1", "Sqrt", "Asin",
"Logit"),
XREGS = NULL,
Lags = c(1:5),
MA_Periods = c(1:5),
SD_Periods = NULL,
Skew_Periods = NULL,
Kurt_Periods = NULL,
Quantile_Periods = NULL,
Quantiles_Selected = NULL,
AnomalyDetection = NULL,
Difference = TRUE,
FourierTerms = 6,
CalendarVariables = c("second", "minute", "hour", "wday", "mday", "yday", "week",
"wom", "isoweek", "month", "quarter", "year"),
HolidayVariable = c("USPublicHolidays", "EasterGroup", "ChristmasGroup",
"OtherEcclesticalFeasts"),
HolidayLookback = NULL,
HolidayLags = 1,
HolidayMovingAverages = 1:2,
TimeTrendVariable = FALSE,
DataTruncate = FALSE,
ZeroPadSeries = NULL,
SplitRatios = c(0.7, 0.2, 0.1),
EvalMetric = "rmse",
NumOfParDepPlots = 0L,
GridTune = FALSE,
ModelCount = 1,
NTrees = 1000,
LearnRate = 0.1,
LearnRateAnnealing = 1,
GridStrategy = "Cartesian",
MaxRunTimeSecs = 60 * 60 * 24,
StoppingRounds = 10,
MaxDepth = 20,
SampleRate = 0.632,
MTries = -1,
ColSampleRate = 1,
ColSampleRatePerTree = 1,
ColSampleRatePerTreeLevel = 1,
MinRows = 1,
NBins = 20,
NBinsCats = 1024,
NBinsTopLevel = 1024,
CategoricalEncoding = "AUTO",
HistogramType = "AUTO",
Distribution = "gaussian",
Link = "identity",
RandomDistribution = NULL,
RandomLink = NULL,
Solver = "AUTO",
Alpha = NULL,
Lambda = NULL,
LambdaSearch = FALSE,
NLambdas = -1,
Standardize = TRUE,
RemoveCollinearColumns = FALSE,
InterceptInclude = TRUE,
NonNegativeCoefficients = FALSE,
RandomColNumbers = NULL,
InteractionColNumbers = NULL
)
AlgoType |
Select from "dfr" for RandomForecast, "gbm" for gradient boosting, "glm" for generalized linear model, "automl" for H2O's AutoML algo, and "gam" for H2O's Generalized Additive Model. |
ExcludeAlgos |
For use when AlgoType = "AutoML". Selections include "DRF","GLM","XGBoost","GBM","DeepLearning" and "Stacke-dEnsemble" |
data |
Supply your full series data set here |
TrainOnFull |
Set to TRUE to train on full data |
TargetColumnName |
List the column name of your target variables column. E.g. "Target" |
PDFOutputPath |
NULL or a path file to output PDFs to a specified folder |
SaveDataPath |
NULL Or supply a path. Data saved will be called 'ModelID'_data.csv |
TimeWeights |
1 or a value between zero and 1. Data will be weighted less and less the more historic it gets, by group |
NonNegativePred |
TRUE or FALSE |
RoundPreds |
Rounding predictions to an integer value. TRUE or FALSE. Defaults to FALSE |
DateColumnName |
List the column name of your date column. E.g. "DateTime" |
GroupVariables |
Defaults to NULL. Use NULL when you have a single series. Add in GroupVariables when you have a series for every level of a group or multiple groups. |
HierarchGroups |
Vector of hierachy categorical columns. |
TimeUnit |
List the time unit your data is aggregated by. E.g. "1min", "5min", "10min", "15min", "30min", "hour", "day", "week", "month", "quarter", "year". |
TimeGroups |
Select time aggregations for adding various time aggregated GDL features. |
FC_Periods |
Set the number of periods you want to have forecasts for. E.g. 52 for weekly data to forecast a year ahead |
PartitionType |
Select "random" for random data partitioning "time" for partitioning by time frames |
MaxMem |
Set to the maximum amount of memory you want to allow for running this function. Default is "32G". |
NThreads |
Set to the number of threads you want to dedicate to this function. |
Timer |
Set to FALSE to turn off the updating print statements for progress |
DebugMode |
Defaults to FALSE. Set to TRUE to get a print statement of each high level comment in function |
TargetTransformation |
Run Rodeo::AutoTransformationCreate() to find best transformation for the target variable. Tests YeoJohnson, BoxCox, and Asigh (also Asin and Logit for proportion target variables). |
Methods |
Choose from "YeoJohnson", "BoxCox", "Asinh", "Log", "LogPlus1", "Sqrt", "Asin", or "Logit". If more than one is selected, the one with the best normalization pearson statistic will be used. Identity is automatically selected and compared. |
XREGS |
Additional data to use for model development and forecasting. Data needs to be a complete series which means both the historical and forward looking values over the specified forecast window needs to be supplied. |
Lags |
Select the periods for all lag variables you want to create. E.g. c(1:5,52) or list("day" = c(1:10), "weeks" = c(1:4)) |
MA_Periods |
Select the periods for all moving average variables you want to create. E.g. c(1:5,52) or list("day" = c(2:10), "weeks" = c(2:4)) |
SD_Periods |
Select the periods for all moving standard deviation variables you want to create. E.g. c(1:5,52) or list("day" = c(2:10), "weeks" = c(2:4)) |
Skew_Periods |
Select the periods for all moving skewness variables you want to create. E.g. c(1:5,52) or list("day" = c(2:10), "weeks" = c(2:4)) |
Kurt_Periods |
Select the periods for all moving kurtosis variables you want to create. E.g. c(1:5,52) or list("day" = c(2:10), "weeks" = c(2:4)) |
Quantile_Periods |
Select the periods for all moving quantiles variables you want to create. E.g. c(1:5,52) or list("day" = c(2:10), "weeks" = c(2:4)) |
Quantiles_Selected |
Select from the following c("q5","q10","q15","q20","q25","q30","q35","q40","q45","q50","q55","q60","q65","q70","q75","q80","q85","q90","q95") |
AnomalyDetection |
NULL for not using the service. Other, provide a list, e.g. AnomalyDetection = list("tstat_high" = 4, tstat_low = -4) |
Difference |
Puts the I in ARIMA for single series and grouped series. |
FourierTerms |
Set to the max number of pairs. E.g. 2 means to generate two pairs for by each group level and interations if hierarchy is enabled. |
CalendarVariables |
NULL, or select from "second", "minute", "hour", "wday", "mday", "yday", "week", "isoweek", "month", "quarter", "year" |
HolidayVariable |
NULL, or select from "USPublicHolidays", "EasterGroup", "ChristmasGroup", "OtherEcclesticalFeasts" |
HolidayLookback |
Number of days in range to compute number of holidays from a given date in the data. If NULL, the number of days are computed for you. |
HolidayLags |
Number of lags to build off of the holiday count variable. |
HolidayMovingAverages |
Number of moving averages to build off of the holiday count variable. |
TimeTrendVariable |
Set to TRUE to have a time trend variable added to the model. Time trend is numeric variable indicating the numeric value of each record in the time series (by group). Time trend starts at 1 for the earliest point in time and increments by one for each success time point. |
DataTruncate |
Set to TRUE to remove records with missing values from the lags and moving average features created |
ZeroPadSeries |
NULL to do nothing. Otherwise, set to "maxmax", "minmax", "maxmin", "minmin". See |
SplitRatios |
E.g c(0.7,0.2,0.1) for train, validation, and test sets |
EvalMetric |
Select from "RMSE", "MAE", "MAPE", "Poisson", "Quantile", "LogLinQuantile", "Lq", "SMAPE", "R2", "MSLE", "MedianAbsoluteError" |
NumOfParDepPlots |
Set to zeros if you do not want any returned. Can set to a very large value and it will adjust to the max number of features if it's too high |
GridTune |
Set to TRUE to run a grid tune |
ModelCount |
Set the number of models to try in the grid tune |
NTrees |
Select the number of trees you want to have built to train the model |
LearnRate |
Default 0.10, models available include gbm |
LearnRateAnnealing |
Default 1, models available include gbm |
GridStrategy |
Default "Cartesian", models available include |
MaxRunTimeSecs |
Default 60*60*24, models available include |
StoppingRounds |
Default 10, models available include |
MaxDepth |
Default 20, models available include drf, gbm |
SampleRate |
Default 0.632, models available include drf, gbm |
MTries |
Default 1, models available include drf |
ColSampleRate |
Default 1, model available include gbm |
ColSampleRatePerTree |
Default 1, models available include drf, gbm |
ColSampleRatePerTreeLevel |
Default 1, models available include drf, gbm |
MinRows |
Default 1, models available include drf, gbm |
NBins |
Default 20, models available include drf, gbm |
NBinsCats |
Default 1024, models available include drf, gbm |
NBinsTopLevel |
Default 1024, models available include drf, gbm |
CategoricalEncoding |
Default "AUTO". Choices include : "AUTO", "Enum", "OneHotInternal", "OneHotExplicit", "Binary", "Eigen", "LabelEncoder", "Sort-ByResponse", "EnumLimited" |
HistogramType |
Default "AUTO". Select from "AUTO", "UniformAdaptive", "Random", "QuantilesGlobal", "RoundRobin" |
Distribution |
Model family |
Link |
Link for model family |
RandomDistribution |
Default NULL |
RandomLink |
Default NULL |
Solver |
Model optimizer |
Alpha |
Default NULL |
Lambda |
Default NULL |
LambdaSearch |
Default FALSE, |
NLambdas |
Default -1 |
Standardize |
Default TRUE |
RemoveCollinearColumns |
Default FALSE |
InterceptInclude |
Default TRUE |
NonNegativeCoefficients |
Default FALSE |
RandomColNumbers |
NULL |
InteractionColNumbers |
NULL |
See examples
Adrian Antico
Other Automated Panel Data Forecasting:
AutoCatBoostCARMA()
,
AutoLightGBMCARMA()
,
AutoXGBoostCARMA()
## Not run:
# Load data
data <- data.table::fread("https://www.dropbox.com/s/2str3ek4f4cheqi/walmart_train.csv?dl=1")
# Ensure series have no missing dates (also remove series with more than 25% missing values)
data <- AutoQuant::TimeSeriesFill(
data,
DateColumnName = "Date",
GroupVariables = c("Store","Dept"),
TimeUnit = "weeks",
FillType = "maxmax",
MaxMissingPercent = 0.25,
SimpleImpute = TRUE)
# Set negative numbers to 0
data <- data[, Weekly_Sales := data.table::fifelse(Weekly_Sales < 0, 0, Weekly_Sales)]
# Remove IsHoliday column
data[, IsHoliday := NULL]
# Create xregs (this is the include the categorical variables instead of utilizing only the interaction of them)
xregs <- data[, .SD, .SDcols = c("Date", "Store", "Dept")]
# Change data types
data[, ":=" (Store = as.character(Store), Dept = as.character(Dept))]
xregs[, ":=" (Store = as.character(Store), Dept = as.character(Dept))]
# Build forecast
Results <- AutoQuant::AutoH2OCARMA(
# Data Artifacts
AlgoType = "drf",
ExcludeAlgos = NULL,
data = data,
TargetColumnName = "Weekly_Sales",
DateColumnName = "Date",
HierarchGroups = NULL,
GroupVariables = c("Dept"),
TimeUnit = "week",
TimeGroups = c("weeks","months"),
# Data Wrangling Features
SplitRatios = c(1 - 10 / 138, 10 / 138),
PartitionType = "random",
# Production args
FC_Periods = 4L,
TrainOnFull = FALSE,
MaxMem = {gc();paste0(as.character(floor(max(32, as.numeric(system("awk '/MemFree/ {print $2}' /proc/meminfo", intern=TRUE)) -32) / 1000000)),"G")},
NThreads = parallel::detectCores(),
PDFOutputPath = NULL,
SaveDataPath = NULL,
Timer = TRUE,
DebugMode = TRUE,
# Target Transformations
TargetTransformation = FALSE,
Methods = c("BoxCox", "Asinh", "Asin", "Log",
"LogPlus1", "Sqrt", "Logit", "YeoJohnson"),
Difference = FALSE,
NonNegativePred = FALSE,
RoundPreds = FALSE,
# Calendar features
CalendarVariables = c("week", "wom", "month", "quarter", "year"),
HolidayVariable = c("USPublicHolidays","EasterGroup",
"ChristmasGroup","OtherEcclesticalFeasts"),
HolidayLookback = NULL,
HolidayLags = 1:7,
HolidayMovingAverages = 2:7,
TimeTrendVariable = TRUE,
# Time series features
Lags = list("weeks" = c(1:4), "months" = c(1:3)),
MA_Periods = list("weeks" = c(2:8), "months" = c(6:12)),
SD_Periods = NULL,
Skew_Periods = NULL,
Kurt_Periods = NULL,
Quantile_Periods = NULL,
Quantiles_Selected = NULL,
# Bonus Features
XREGS = NULL,
FourierTerms = 2L,
AnomalyDetection = NULL,
ZeroPadSeries = NULL,
DataTruncate = FALSE,
# ML evaluation args
EvalMetric = "RMSE",
NumOfParDepPlots = 0L,
# ML grid tuning args
GridTune = FALSE,
GridStrategy = "Cartesian",
ModelCount = 5,
MaxRunTimeSecs = 60*60*24,
StoppingRounds = 10,
# ML Args
NTrees = 1000L,
MaxDepth = 20,
SampleRate = 0.632,
MTries = -1,
ColSampleRatePerTree = 1,
ColSampleRatePerTreeLevel = 1,
MinRows = 1,
NBins = 20,
NBinsCats = 1024,
NBinsTopLevel = 1024,
HistogramType = "AUTO",
CategoricalEncoding = "AUTO",
RandomColNumbers = NULL,
InteractionColNumbers = NULL,
WeightsColumn = NULL,
# ML args
Distribution = "gaussian",
Link = "identity",
RandomDistribution = NULL,
RandomLink = NULL,
Solver = "AUTO",
Alpha = NULL,
Lambda = NULL,
LambdaSearch = FALSE,
NLambdas = -1,
Standardize = TRUE,
RemoveCollinearColumns = FALSE,
InterceptInclude = TRUE,
NonNegativeCoefficients = FALSE)
UpdateMetrics <-
Results$ModelInformation$EvaluationMetrics[
Metric == "MSE", MetricValue := sqrt(MetricValue)]
print(UpdateMetrics)
# Get final number of trees actually used
Results$Model@model$model_summary$number_of_internal_trees
# Inspect performance
Results$ModelInformation$EvaluationMetricsByGroup[order(-R2_Metric)]
Results$ModelInformation$EvaluationMetricsByGroup[order(MAE_Metric)]
Results$ModelInformation$EvaluationMetricsByGroup[order(MSE_Metric)]
Results$ModelInformation$EvaluationMetricsByGroup[order(MAPE_Metric)]
## End(Not run)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.