Need help with RemixAutoML?

Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

153 Stars 36 Forks Mozilla Public License 2.0 4.4K Commits 1 Opened issues

R package for automation of machine learning, forecasting, feature engineering, model evaluation, model interpretation, data generation, and recommenders.

Readme

> Automated Machine Learning - In my view, AutoML should consist of functions to help make professional model development and operationalization more efficient. Most ML projects include at least one of the following: data wrangling, feature engineering, feature selection, model development, model evaluation, model interpretation, model optimization, and model operationalization. The functions in this package have been tested across a variety of industries and have consistently out-performd "state of the art" deep learning methods. I've watched coworkers spend months tuning and reconfiguring deep learning models just to have them lose to the functions here, in a matter of a day or two. My recommendation is to first utilize the functions here to establish a legit baseline performance. Then go and test out all the other methods.

> Supervised Learning - Currently, I'm utilizing CatBoost, XGBoost, and H2O for all of the automated Machine Learning related functions. GPU's can be utilized with CatBoost and XGBoost. Multi-armed bandit grid tuning is available for CatBoost and XGBoost models, which utilize the concept of randomized probability matching, which is detailed in the R pacakge "bandit".

> Time series forecasting - Automated functions for single series, panel data, vector autoregression, intermittent demand, and cohort panel data. The panel data models utilize the machine learning algos from above and the feature engineering functions below. They are extremely feature rich and the combination of all possible feature settings is huge. The models for individual series are fully optimized versions from the R package "forecast". I utilize the multi-armed bandit grid tuning algo used in the supervised learning models and apply it to the SARIMA and NNETAR models from the forecast package. I also measure performance on hold out data (and training data, or a blend of the two).

> Feature Engineering - Some of the feature engineering functions you can only find in this package, such as the `AutoLagRollStats()`

and `AutoLagRollStatsScoring()`

functions. You could classify the above functions into several buckets: categorical encoding, target encoding, and distributed lag. You can generate any number of discontiguous lags and rolling statistics (mean, sd, skewness, kurtosis, and every 5th percentile) along with time between records and their associated lags and rolling statistics for transactional level data. The function runs extremely fast if you don't utilize rolling stats other than mean (I still use `data.table::frollapply()`

but the data.table guys admit it isn't optimized like the `data.table::frollmean()`

function). Furthermore, you can generate all these features by any number of categorical variables and their interactions PLUS you can request those sets of features to be generated for differnt levels of time aggregations such as transactional, hourly, daily, weekly, monthly, quarterly, and yearly, all in one shot (that is, you do not have to run the function repeatedly to generate the features). Lastly, generating these kinds of time series features on the fly for only a subset of records in a data.table (typically for on-demand model scoring) is not an easy task to do correctly and quickly. However, I spent the time to make it run as fast as I could but I am open to suggestions for making it faster (that goes for any of the functions in RemixAutoML).

> Data Management - Every function here is written with fully-optimized data.table code so they run blazingly fast and are as memory efficient as possible. The current set of machine learning algorithms were chosen for their ability to work with big data and their ability to outperform other models, as demonstrated across a variety of real world use cases. The focus of the package is quality, not quantity.

> Documentation - Each exported function in the package has a help file and can be viewed in your RStudio session, e.g. `?RemixAutoML::ModelDataPrep`

. Many of them come with examples coded up in the help files (at the bottom) that you can run to get a feel for how to set the parameters. There's also a listing of exported functions by category with code examples at the bottom of this readme. You can also jump into the R folder here to dig into the source code.

XGBoost runs significantly faster with GPU (it's already pretty fast on CPU) but it can be tricky to get installed. The blog below has been shown to be reliable for getting it done. Install XGBoost on Windows for R with GPU Capability

```
# Install Dependencies----
if(!("remotes" %in% rownames(installed.packages()))) install.packages("remotes"); print("remotes")
if(!("arules" %in% rownames(installed.packages()))) install.packages("arules"); print("arules")
if(!("bit64" %in% rownames(installed.packages()))) install.packages("bit64"); print("bit64")
if(!("caTools" %in% rownames(installed.packages()))) install.packages("caTools"); print("caTools")
if(!("combinat" %in% rownames(install.packages()))) install.packages("combinat"); print("combinat")
if(!("data.table" %in% rownames(installed.packages()))) install.packages("data.table"); print("data.table")
if(!("doParallel" %in% rownames(installed.packages()))) install.packages("doParallel"); print("doParallel")
if(!("e1071" %in% rownames(installed.packages()))) install.packages("e1071"); print("e1071")
if(!("fBasics" %in% rownames(installed.packages()))) install.packages("fBasics"); print("fBasics")
if(!("foreach" %in% rownames(installed.packages()))) install.packages("foreach"); print("foreach")
if(!("forecast" %in% rownames(installed.packages()))) install.packages("forecast"); print("forecast")
if(!("fpp" %in% rownames(installed.packages()))) install.packages("fpp"); print("fpp")
if(!("ggplot2" %in% rownames(installed.packages()))) install.packages("ggplot2"); print("ggplot2")
if(!("gridExtra" %in% rownames(installed.packages()))) install.packages("gridExtra"); print("gridExtra")
if(!("here" %in% rownames(installed.packages()))) install.packages("here"); print("here")
if(!("itertools" %in% rownames(installed.packages()))) install.packages("itertools"); print("itertools")
if(!("lime" %in% rownames(installed.packages()))) install.packages("lime"); print("lime")
if(!("lubridate" %in% rownames(installed.packages()))) install.packages("lubridate"); print("lubridate")
if(!("Matrix" %in% rownames(installed.packages()))) install.packages("Matrix"); print("Matrix")
if(!("MLmetrics" %in% rownames(installed.packages()))) install.packages("MLmetrics"); print("MLmetrics")
if(!("monreg" %in% rownames(installed.packages()))) install.packages("monreg"); print("monreg")
if(!("nortest" %in% rownames(installed.packages()))) install.packages("nortest"); print("nortest")
if(!("RColorBrewer" %in% rownames(installed.packages()))) install.packages("RColorBrewer"); print("RColorBrewer")
if(!("recommenderlab" %in% rownames(installed.packages()))) install.packages("recommenderlab"); print("recommenderlab")
if(!("ROCR" %in% rownames(installed.packages()))) install.packages("ROCR"); print("ROCR")
if(!("pROC" %in% rownames(installed.packages()))) install.packages("pROC"); print("pROC")
if(!("Rfast" %in% rownames(installed.packages()))) install.packages("Rfast"); print("Rfast")
if(!("scatterplot3d" %in% rownames(installed.packages()))) install.packages("scatterplot3d"); print("scatterplot3d")
if(!("stringr" %in% rownames(installed.packages()))) install.packages("stringr"); print("stringr")
if(!("sde" %in% rownames(installed.packages()))) install.packages("sde"); print("sde")
if(!("timeDate" %in% rownames(installed.packages()))) install.packages("timeDate"); print("timeDate")
if(!("tsoutliers" %in% rownames(installed.packages()))) install.packages("tsoutliers"); print("tsoutliers")
if(!("wordcloud" %in% rownames(installed.packages()))) install.packages("wordcloud"); print("wordcloud")
if(!("xgboost" %in% rownames(installed.packages()))) install.packages("xgboost"); print("xgboost")
for (pkg in c("RCurl","jsonlite")) if (! (pkg %in% rownames(installed.packages()))) { install.packages(pkg) }
install.packages("h2o", type = "source", repos = (c("http://h2o-release.s3.amazonaws.com/h2o/latest_stable_R")))
remotes::install_github('catboost/catboost', subdir = 'catboost/R-package')
remotes::install_github('AdrianAntico/RemixAutoML', upgrade = FALSE, dependencies = FALSE, force = TRUE)
```

The most common issue some users are having when trying to install `RemixAutoML`

is the installation of the `catboost`

package dependency. Since `catboost`

is not on CRAN it can only be installed through GitHub. To install `catboost`

without error (and consequently install `RemixAutoML`

without error), try running this line of code first, then restart your R session, then re-run the 2-step installation process above. (Reference):
If you're still having trouble submit an issue and I'll work with you to get it installed.

```
# Be sure to use the version you want versus what is listed below
options(devtools.install.args = c("--no-multiarch", "--no-test-load"))
install.packages("https://github.com/catboost/catboost/releases/download/v0.17.3/catboost-R-Windows-0.17.3.tgz", repos = NULL, type = "source", INSTALL_opts = c("--no-multiarch", "--no-test-load"))
```

If you're having still having trouble installing see if the issue below helps out:

- Pull in data from your data warehouse (or from wherever) and clean it up
- Run all the applicable feature engineering functions, such as
`AutoLagRollStats()`

,`AutoWord2VecModeler()`

,`CreateCalendarVariables()`

,`CreateHolidayVariables()`

, etc. - Partition your data with
`AutoDataPartition()`

if you want to go with a data split other than 70/20/10, which is automatically applied in the supervised learning functions if you don't supply the ValidationData and TestData (and TrainOnFull is set to FALSE). - Run
`AutoCatBoostRegression()`

or`AutoCatBoostClassifier()`

or`AutoCatBoostMultiClass()`

with GPU if you have access to one - Run
`AutoXGBoostRegression()`

or`AutoXGBoostClassifier()`

or`AutoXGBoostMultiClass()`

with GPU if you have access to one - Run
`AutoH2oGBMRegression()`

or`AutoH2oGBMClassifier()`

or`AutoH2oGBMMultiClass()`

if you have the patience to wait for a CPU build. - Run
`AutoH2oGLMRegression()`

or`AutoH2oGLMClassifier()`

or`AutoH2oGLMMultiClass()`

if you want to give a generalized linear model a shot. - Run
`AutoH2oMLRegression()`

or`AutoH2oMLClassifier()`

or`AutoH2oMLMultiClass()`

to run H2O's AutoML function inside the RemixAutoML framework. - Run
`AutoH2oDRFRegression()`

or`AutoH2oDRFClassifier()`

or`AutoH2oDRFMultiClass()`

H2O's Distributed Random Forest can take a really long time to build. H2O's documentation has a great explanation for the reason why it takes much longer compared to their GBM algo. - Investigate model performance contained in the output object returned by those functions. You will be able to look at model calibration plots or box plots, ROC plots, partial depence calibration plots or boxplots, model metrics, etc.
- If you ran one of the
`Auto__Classifer()`

function supply the validation to the function`RemixClassificationMetrics()`

for an exhaustive threshold analysis - Pick your model of choice and kick off an extended grid tuning and figure out something else to do that week (or run it over the weekend).
- Compare your results with your coworkers results and see what's working and what isn't. Then you can either move on or continue exploring. Bargain with your boss to get that time to explore so you can learn new things.

Supply a data.table to run the functions below:

- For single series check out
`AutoBanditSarima()`

,`AutoBanditNNet()`

,`AutoTBATS()`

,`AutoETS()`

,`AutoArfima()`

, or`AutoTS()`

(older function; no longer developing) - For panel data OR single series check out
`AutoCatBoostCARMA()`

,`AutoXGBoostCARMA()`

,`AutoH2OCARMA()`

,`AutoCatBoostHurdleCARMA`

or`AutoCatBoostVectorCARMA`

or build a loop and run functions from (1) - If you have to do any funnel forecasting, check out AutoCatBoostChainLadder(). First you need to structure you data like the help example. When you think you have found a good configuration, set the parameter SaveModelObjects = TRUE. Then you can run the AutoMLChainLadderForecasting().

The Most Feature Rich ML Forecasting Methods Available

AutoML Frameworks in R & Python

AI for Small to Medium Size Businesses: A Management Take On The Challenges...

Why Machine Learning is more Practical than Econometrics in the Real World

Build Thousands of Automated Demand Forecasts in 15 Minutes Using AutoCatBoostCARMA in R

Automate Your KPI Forecasts With Only 1 Line of R Code Using AutoTS

Companies Are Demanding Model Interpretability. Here’s How To Do It Right

The Easiest Way to Create Thresholds And Improve Your Classification Model

```
# Create fake Panel Data----
Count
</p></details>
<details><summary>Code Example</summary>
<p>
```

Count

`AutoLagRollStats()`

builds lags and rolling statistics by grouping variables and their interactions along with multiple different time aggregations if selected. Rolling stats include mean, sd, skewness, kurtosis, and the 5th - 95th percentiles. This function was inspired by the distributed lag modeling framework but I wanted to use it for time series analysis as well and really generalize it as much as possible. The beauty of this function is inspired by analyzing whether a baseball player will get a basehit or more in his next at bat. One easy way to get a better idea of the likelihood is to look at his batting average and his career batting average. However, players go into hot streaks and slumps. How do we account for that? Well, in comes the functions here. You look at the batting average over the last N to N+x at bats, for various N and x. I keep going though - I want the same windows for calculating the players standard deviation, skewness, kurtosis, and various quantiles over those time windows. I also want to look at all those measure but by using weekly data - as in, over the last N weeks, pull in those stats too.

`AutoLagRollStatsScoring()`

builds the above features for a partial set of records in a data set. The function is extremely useful as it can compute these feature vectors at a significantly faster rate than the non scoring version which comes in handy for scoring ML models. If you can find a way to make it faster, let me know.

```
#########################################
# Feature Engineering for Model Training
#########################################
# Create fake data
data
</p></details>
<details><summary>Function Description</summary>
<p>
<code>AutoInteraction()</code> will build out any number of interactions you want for numeric variables. You supply a character vector of numeric or integer column names, along with the names of any numeric columns you want to skip (including the interaction column names) and the interactions will be automatically created for you. For example, if you want a 4th degree interaction from 10 numeric columns, you will have 10 C 2, 10 C 3, and 10 C 4 columns created. Now, let's say you build all those features and decide you don't want all 10 features to be included. Remove the feature name from the NumericVars character vector. Now, let's say you modeled all of the interaction features and want to remove the ones will the lowest scores on the variable importance list. Grab the names and run the interaction function again except this time supply those poor performing interaction column names to the SkipCols argument and they will be ignored. Now, if you want to interact any categorical variable with a numeric variable, you'll have to dummify the categorical variable first and then include the level specific dummy variable column names to the NumericVars character vector argument. If you set Center and Scale to TRUE then the interaction multiplication won't create huge numbers.
</p>
</details>
<h4><strong>AutoWord2VecModeler()</strong></h4>
<details><summary>Function Description</summary>
<p>
<code>AutoWord2VecModeler()</code> generates a specified number of vectors (word2vec) for each column of text data in your data set that you specify and it will save the models if you specify for re-creating them later in a model scoring process. You can choose to build individual models for each column or one model for all your columns. If you need to run several models for groups of text variables you can run the function several times.
</p>
</details>
<h4><strong>CreateCalendarVariables()</strong></h4>
<details><summary>Code Example</summary>
<p>
```

data

`CreateCalendarVariables()`

This functions creates numerical columns based on the date columns you supply such as second, minute, hour, week day, day of month, day of year, week, isoweek, wom, month, quarter, and year.

```
# Create fake data with a Date----
data
</p></details>
<details><summary>Function Description</summary>
<p>
<code>CreateHolidayVariable()</code>
This function counts up the number of specified holidays between the current record time stamp and the previous record time stamp, by group as well if specified.
</p>
</details>
<h4><strong>AutoHierarchicalFourier()</strong></h4>
<details><summary>Function Description</summary>
<p>
<code>AutoHierarchicalFourier()</code> turns time series data into fourier series. This function can generate any number of fourier pairs the user wants (if they can actually build) and you can run it with grouped time series data. In the grouping case, fourier pairs can be created for each categorical variable along with the full interactions between specified categoricals. The process is parallelized as well to run as fast as possible.
</p>
</details>
<h4>
<strong>AutoTransformationCreate()</strong> and <strong>AutoTransformationScore()</strong>
</h4>
<details><summary>Descriptions</summary>
<p>
<code>AutoTransformationCreate()</code> is a function for automatically identifying the optimal transformations for numeric features and transforming them once identified. This function will loop through your selected transformation options (YeoJohnson, BoxCox, Asinh, Log, LogPlus1, Sqrt, along with Asin and Logit for proportion data) and find the one that produces the best fit to a normal distribution. It then generates the transformation and collects the metadata information for use in the AutoTransformationScore() function, either by returning the objects or saving them to file.
<code>AutoTransformationScore()</code> is a the compliment function to AutoTransformationCreate(). Automatically apply or inverse the transformations you identified in AutoTransformationCreate() to other data sets. This is useful for applying transformations to your validation and test data sets for modeling, which is done automatically for you if you specify.
</p>
</details>
<h4><strong>ModelDataPrep()</strong></h4>
<details><summary>Code Example</summary>
<p>
```

data

`ModelDataPrep()`

This function will loop through every column in your data and apply a variety of functions based on argument settings. For all columns not ignored, these tasks include:

- Character type to Factor type converstion
- Factor type to Character type conversion
- Constant value imputation for numeric and categorical columns
- Integer type to Numeric type conversion
- Date type to Character type conversion
- Remove date columns
- Ignore specified columns

```
# Create fake data with 10 categorical columns
data
</p></details>
<details><summary>Function Description</summary>
<p>
<code>DummifyDT()</code> This function is used in the AutoXGBoost__() suite of modeling functions to manage categorical variables in your training, validation, and test sets. This function rapidly dichotomizes categorical columns in a data.table (N+1 columns for N levels using one hot encoding or N columns for N levels otherwise). Several other arguments exist for outputting and saving factor levels. This is useful in model training, validating, and scoring processes.
</p>
</details>
<h4>
<strong>DifferenceData()</strong> and <strong>DifferenceDataReverse()</strong>
</h4>
<details><summary>Function Description</summary>
<p>
<code>DifferenceData()</code> Create differences in your data (y1 - y0) for grouped or non-grouped data. <code>DifferenceDataReverse()</code> Reverses the differences in your data for grouped or non-grouped data.
</p>
</details>
<h4><strong>AutoDataPartition()</strong></h4>
<details><summary>Code Example</summary>
<p>
```

data

`AutoDataPartition()`

is designed to achieve a few things that standard data partitioning processes or functions don't handle. First, you can choose to build any number of partitioned data sets beyond the standard train, validate, and test data sets. Second, you can choose between random sampling to split your data or you can choose a time-based partitioning. Third, for the random partitioning, you can specify a stratification columns in your data to stratify by in order to ensure a proper split amongst your categorical features (E.g. think MultiClass targets). Lastly, it's 100% data.table so it will run fast and with low memory overhead.

`AutoCatBoostRegression()`

utilizes the CatBoost algorithm in the below steps

```
# Create some dummy correlated data
data
</p></details>
</p>
<h4>
<strong>AutoXGBoostRegression()</strong> GPU Capable</h4>
<p><code>AutoXGBoostRegression()</code> utilizes the XGBoost algorithm in the below steps </p>
<details><summary>Code Example</summary>
<p>
```

#' # Create some dummy correlated data #' data

`AutoH2oGBMRegression()`

utilizes the H2O Gradient Boosting algorithm in the below steps

```
# Create some dummy correlated data
data
</p></details>
<h4><strong>AutoH2oDRFRegression()</strong></h4>
<p><code>AutoH2oDRFRegression()</code> utilizes the H2o Distributed Random Forest algorithm in the below steps </p>
<details><summary>Code Example</summary>
<p>
```

data

`AutoH2oGLMRegression()`

utilizes the H2o generalized linear model algorithm in the below steps

```
# Create some dummy correlated data
data
</p></details>
<h4><strong>AutoH2oMLRegression()</strong></h4>
<p><code>AutoH2oMLRegression()</code> utilizes the H2o AutoML algorithm in the below steps </p>
<details><summary>Code Example</summary>
<p>
```

data

`AutoH2oGLMRegression()`

utilizes the H2o generalized linear model algorithm in the below steps

```
# Create some dummy correlated data
data
</p></details>
<h4>The Auto_Regression() models handle a multitude of tasks. In order:</h4>
<ol>
<li>Convert your data to data.table format for faster processing</li>
<li>Transform your target variable using the best normalization method based on the <code>AutoTransformationCreate()</code> function</li>
<li>Create train, validation, and test data, utilizing the <code>AutoDataPartition()</code> function, if you didn't supply those directly to the function</li>
<li>Consoldate columns that are used for modeling and what metadata you want returned in your test data with predictions</li>
<li>Dichotomize categorical variables (for <code>AutoXGBoostRegression()</code>) and save the factor levels for scoring in a way that guarentees consistency across training, validation, and test data sets, utilizing the <code>DummifyDT()</code> function</li>
<li>Save the final modeling column names for reference</li>
<li>Handles the data conversion to the appropriate modeling type, such as CatBoost, H2O, and XGBoost</li>
<li>Multi-armed bandit hyperparameter tuning using randomized probability matching, if you choose to grid tune</li>
<li>Loop through the grid-tuning process, building N models</li>
<li>Collect the evaluation metrics for each grid tune run</li>
<li>Identify the best model of the set of models built in the grid tuning search</li>
<li>Save the hyperparameters from the winning grid tuned model</li>
<li>Build the final model based on the best model from the grid tuning model search (I remove each model after evaluation metrics are generated in the grid tune to avoid memory overflow)</li>
<li>Back-transform your predictions based on the best transformation used earlier in the process</li>
<li>Collect evaluation metrics based on performance on test data (based on back-transformed data)</li>
<li>Store the final predictions with the associated test data and other columns you want included in that set</li>
<li>Save your transformation metadata for recreating them in a scoring process</li>
<li>Build out and save an Evaluation Calibration Line Plot and Evaluation Calibration Box-Plot, using the <code>EvalPlot()</code> function</li>
<li>Generate and save Variable Importance</li>
<li>Generate and save Partital Dependence Calibration Line Plots and Partital Dependence Calibration Box-Plots, using the <code>ParDepPlots()</code> function</li>
<li>Return all the objects generated in a named list for immediate use and evaluation</li>
</ol>
<p></p>
</details></p>
<h4>Binary Classification</h4>
<hr>
<details><summary>click to expand</summary>
<p>
#### **AutoCatBoostClassifier()** GPU Capable
<code>AutoCatBoostClassifier()</code> utilizes the CatBoost algorithm in the below steps
<details><summary>Code Example</summary>
<p>
```

data

`AutoXGBoostClassifier()`

utilizes the XGBoost algorithm in the below steps

```
# Create some dummy correlated data
data
</p></details>
<h4><strong>AutoH2oGBMClassifier()</strong></h4>
<p><code>AutoH2oGBMClassifier()</code> utilizes the H2O Gradient Boosting algorithm in the below steps</p>
<details><summary>Code Example</summary>
<p>
```

data

`AutoH2oDRFClassifier()`

utilizes the H2O Distributed Random Forest algorithm in the below steps

```
# Create some dummy correlated data
data
</p></details>
<h4><strong>AutoH2oGLMClassifier()</strong></h4>
<p><code>AutoH2oGLMClassifier()</code> utilizes the H2O generalized linear model algorithm in the below steps</p>
<details><summary>Code Example</summary>
<p>
```

data

`AutoH2oMLClassifier()`

utilizes the H2o AutoML algorithm in the below steps

```
# Create some dummy correlated data with numeric and categorical features
data
</p></details>
<h4><strong>AutoH2oGAMClassifier()</strong></h4>
<details><summary>Code Example</summary>
<p>
```

data

- Convert your data to data.table format for faster processing
- Create train, validation, and test data if you didn't supply those directly to the function
- Consoldate columns that are used for modeling and what is to be kept for data returned
- Dichotomize categorical variables (for AutoXGBoostRegression) and save the factor levels for scoring in a way that guarentees consistency across training, validation, and test data sets
- Saves the final column names for modeling to a csv for later reference
- Handles the data conversion to the appropriate type, based on model type (CatBoost, H2O, and XGBoost)
- Multi-armed bandit hyperparameter tuning using randomized probability matching, if you choose to grid tune
- Build the grid tuned models
- Collect the evaluation metrics for each grid tune run
- Identify the best model of the set of models built in the grid tuning setup
- Save the hyperparameters from the winning grid tuned model
- Build the final model based on the best model from the grid tuning model search
- Collect evaluation metrics based on performance on test data
- Store the final predictions with the associated test data and other columns you want included in that set
- Build out and save an Evaluation Calibration Line Plot
- Build out and save an ROC plot with the top 5 models used in grid-tuning (includes the winning model)
- Generate and save Variable Importance data
- Generate and save Partital Dependence Calibration Line Plots
- Return all the objects generated in a named list for immediate use

`AutoCatBoostMultiClass()`

utilizes the CatBoost algorithm in the below steps

```
# Create some dummy correlated data
data
</p></details>
</p>
<h4>
<strong>AutoXGBoostMultiClass()</strong> GPU Capable</h4>
<p><code>AutoXGBoostMultiClass()</code> utilizes the XGBoost algorithm in the below steps</p>
<details><summary>Code Example</summary>
<p>
```

data

`AutoH2oGBMMultiClass()`

utilizes the H2O Gradient Boosting algorithm in the below steps

```
# Create some dummy correlated data
data
</p></details>
<h4><strong>AutoH2oDRFMultiClass()</strong></h4>
<p><code>AutoH2oDRFMultiClass()</code> utilizes the H2O Distributed Random Forest algorithm in the below steps</p>
<details><summary>Code Example</summary>
<p>
```

data

`AutoH2oGLMMultiClass()`

utilizes the H2O generalized linear model algorithm in the below steps

```
# Create some dummy correlated data with numeric and categorical features
data
</p></details>
<h4><strong>AutoH2oMLMultiClass()</strong></h4>
<p><code>AutoH2oMLMultiClass()</code> utilizes the H2o AutoML algorithm in the below steps</p>
<details><summary>Code Example</summary>
<p>
```

data

```
# Create some dummy correlated data with numeric and categorical features
data
</p></details>
<h4>The Auto_MultiClass() models handle a multitude of tasks. In order:</h4>
<ol>
<li>Convert your data to data.table format for faster processing</li>
<li>Create train, validation, and test data if you didn't supply those directly to the function</li>
<li>Consoldate columns that are used for modeling and what is to be kept for data returned</li>
<li>Dichotomize categorical variables (for AutoXGBoostRegression) and save the factor levels for scoring in a way that guarentees consistency across training, validation, and test data sets</li>
<li>Saves the final column names for modeling to a csv for later reference</li>
<li>Ensures the target levels are consistent across train, validate, and test sets and save the levels to file</li>
<li>Handles the data conversion to the appropriate type, based on model type (CatBoost, H2O, and XGBoost)</li>
<li>Multi-armed bandit hyperparameter tuning using randomized probability matching, if you choose to grid tune</li>
<li>Build the grid tuned models</li>
<li>Collect the evaluation metrics for each grid tune run</li>
<li>Identify the best model of the set of models built in the grid tuning setup</li>
<li>Save the hyperparameters from the winning grid tuned model</li>
<li>Build the final model based on the best model from the grid tuning model search</li>
<li>Collect evaluation metrics based on performance on test data</li>
<li>Store the final predictions with the associated test data and other columns you want included in that set</li>
<li>Generate and save Variable Importance data</li>
<li>Return all the objects generated in a named list for immediate use</li>
</ol>
<p></p>
</details>
<h4>Generalized Hurdle Models</h4>
<hr>
<details><summary>click to expand</summary>
<p>
First step is to build either a binary classification model (in the case of a single bucket value, such as zero) or a multiclass model (for the case of multiple bucket values, such as zero and 10). The next step is to subset the data for the cases of: less than the first split value, in between the first and second split value, second and third split value, ..., second to last and last split value, along with greater than last split value. For each data subset, a regression model is built for predicting values in the split value ranges. The final compilation is to multiply the probabilities of being in each group times the values supplied by the regression values for each group.
###### Single Partition
* E(y|x<sub>i</sub>) = Pr(X = 0) * 0 + Pr(X > 0) * E(X | X >= 0)
* E(y|x<sub>i</sub>) = Pr(X < x<sub>1</sub>) * E(X | X < x<sub>1</sub>) + Pr(X >= x<sub>1</sub>) * E(X | X >= x<sub>1</sub>)
###### Multiple Partitions
* E(y|x<sub>i</sub>) = Pr(X = 0) * 0 + Pr(X < x<sub>2</sub>) * E(X | X < x<sub>2</sub>) + ... + Pr(X < x<sub>n</sub>) * E(X | X < x<sub>n</sub>) + Pr(X >= x<sub>n</sub>) * E(X | X >= x<sub>n</sub>)
* E(y|x<sub>i</sub>) = Pr(X < x<sub>1</sub>) * E(X | X < x<sub>1</sub>) + Pr(x<sub>1</sub> <= X < x<sub>2</sub>) * E(X | x<sub>1</sub> <= X < x<sub>2</sub>) + ... + Pr(x<sub>n-1</sub> <= X < x<sub>n</sub>) * E(X | x<sub>n-1</sub> <= X < x<sub>n</sub>) + Pr(X >= x<sub>n</sub>) * E(X | X >= x<sub>n</sub>)
#### **AutoCatBoostHurdleModel()**
<code>AutoCatBoostHurdleModel()</code> utilizes the CatBoost algorithm on the backend.
#### **AutoXGBoostHurdleModel()**
<code>AutoXGBoostHurdleModel()</code> utilizes the XGBoost algorithm on the backend.
#### **AutoH2oDRFHurdleModel()**
<code>AutoH2oDRFHurdleModel()</code> utilizes the H2O distributed random forest algorithm on the backend.
#### **AutoH2oGBMHurdleModel()**
<code>AutoH2oGBMHurdleModel()</code> utilizes the H2O gradient boosting machine algorithm on the backend.
</p>
</details>
<h4>General Purpose H2O Automated Modeling</h4>
<hr>
<details><summary>click to expand</summary>
<p>
#### **AutoH2OModeler()**
<code>AutoH2OModeler()</code> automatically build any number of models along with generating partial dependence calibration plots, model evaluation calibration plots, grid tuning, and file storage for easy production implementation. Handles regression, quantile regression, time until event, and classification models (binary and multinomial) using numeric and factor variables without the need for monotonic transformations nor one-hot-encoding.
* Models include:
* RandomForest (DRF)
* GBM
* Deeplearning
* XGBoost (for Linux)
* LightGBM (for Linux)
* AutoML - medium debth grid tuning for Deeplearning, XGBoost (if available), DRF, GBM, GLM, and StackedEnsembles
</p>
</details>
<h4>Nonlinear Regression Modeling</h4>
<hr>
<details><summary>click to expand</summary>
<p>
#### **AutoNLS()**
<img src="https://github.com/AdrianAntico/RemixAutoML/raw/master/Images/AutoNLS_Image.png" align="center" width="400">
<code>AutoNLS()</code> is an automated nonlinear regression modeling function. This function automatically finds the best model fit from the set of models listed below and merges predictions to source data file. Great for forecasting growth (extrapolation) when domain knowledge can guide model selection.
* Models included:
* Asymptotic
* Asymptotic through origin
* Asymptotic with offset
* Bi-exponential
* Four parameter logistic
* Three parameter logistic
* Gompertz
* Michal Menton
* Weibull
* Polynomial regression or monotonic regression
</p>
</details>
<p></p>
</details>
<h2>Model Scoring <img src="https://github.com/AdrianAntico/RemixAutoML/raw/master/Images/ModelScoringImage.png" align="right" width="80">
</h2>
<details><summary>Expand to view content</summary>
<p>
<details><summary>Code Example</summary>
<p>
```

data

`AutoCatBoostScoring()`

is an automated scoring function that compliments the AutoCatBoost() model training functions. This function requires you to supply features for scoring. It will run ModelDataPrep() to prepare your features for catboost data conversion and scoring. It will also handle and transformations and back-transformations if you utilized that feature in the regression training case.

`AutoXGBoostScoring()`

is an automated scoring function that compliments the AutoXGBoost() model training functions. This function requires you to supply features for scoring. It will run ModelDataPrep() and the DummifyDT() functions to prepare your features for xgboost data conversion and scoring. It will also handle and transformations and back-transformations if you utilized that feature in the regression training case.

`AutoH2OMLScoring()`

is an automated scoring function that compliments the AutoH2oGBM**() and AutoH2oDRF**() model training functions. This function requires you to supply features for scoring. It will run ModelDataPrep()to prepare your features for H2O data conversion and scoring. It will also handle transformations and back-transformations if you utilized that feature in the regression training case and didn't do it yourself before hand.

`AutoHurdleScoring()`

will score the AutoCatBoostHurdleModel() function currently. Functionality for XGBoost hurdle models will be next, followed by the H2O version.

`AutoH2OScoring()`

is for scoring models that were built with the AutoH2OModeler, AutoKMeans, and AutoWord2VecModeler functions. Scores mojo models or binary files by loading models into the H2O environment and scoring them. You can choose which output you wish to keep as well for classification and multinomial models.

`RemixClassificationMetrics()`

will return all confusion matrix metrics across all possible thresholds (seq(0.01,0.99,0.01) for any Remix Auto_Classification() model. Cost sensitive thresholds are also returned.

`ParDepCalPlots()`

is for visualizing the relationships of features and the reliability of the model in predicting those effects. Build a partial dependence calibration line plot, box plot or bar plot for the case of categorical variables.

`EvalPlot()`

Has two plot versions: calibration line plot of predicted values and actual values across range of predicted value, and calibration boxplot for seeing the accuracy and variability of predictions against actuals.

`threshOptim()`

is great for situations with asymmetric costs across the confusion matrix. Generate a cost-sensitive optimized threshold for classification models. Just supply the costs for false positives and false negatives (can supply costs for all four outcomes too) and the function will return the optimal threshold for maximizing "utility".

`RedYellowGreen()`

computes optimal thresholds for binary classification models where "don't classify" is an option. Consider a health care binary classification model that predicts whether or not a disease is present. This is certainly a case for threshOptim since the costs of false positives and false negatives can vary by a large margin. However, there is always the potential to run further analysis. The RedYellowGreen() function can compute two thresholds if you can supply a cost of "further analysis". Predicted values < the lower threshold are confidently classified as a negative case and predicted values > the upper threshold are confidently classified as a postive case. Predicted values in between the lower and upper thresholds are cases that should require further analysis.

```
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# Out-of-Sample Feature + Grid Tuning of RemixAutoML::AutoCatBoostCARMA()
# @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
# Set up your output file path for saving results as a .csv
Path
</p></details>
</p>
<p><img src="https://github.com/AdrianAntico/RemixAutoML/raw/master/Images/TimeSeriesMethods.PNG" align="center" width="750"></p>
<p><code>AutoCatBoostVectorCARMA</code> For Panel Data with multiple series to forecast. An example would be, predicting revenue and transactions across a large number of stores over time.</p>
<p><code>AutoHurdleCARMA()</code> utilizes the AutoCatBoostHurdleModel() function internally in order to model zeros that naturally show up in intermittent demand data sets.</p>
<p><code>AutoCatBoostCARMA()</code> utilizes the CatBoost alorithm</p>
<p><code>AutoXGBoostCARMA()</code> utilizes the XGBoost alorithm</p>
<p><code>AutoH2OCARMA()</code> utilizes H2O Algorithms: RandomForest, GBM, GLM, AutoML, and GAM</p>
<details><summary>Model Highlights</summary>
<p>
##### The CARMA suite utilizes several features to ensure proper models are built to generate the best possible out-of-sample forecasts.
###### **Feature engineering:** I use a time trend, calendar variables, holiday counts, differencing, along with fourier pairs and lags / rolling statistics (mean, sd, skewness, kurtosis, quantiles) and they can be generated by categorical variables and their interactions plus for various time-based aggregations. Internally, the CARMA functions utilize several RemixAutoML functions, all written using data.table for fast and memory efficient processing:
* <code>AutoLagRollStats()</code> - creates lags and moving average features (also creates lags and moving averages off of time between records)
* <code>AutoLagRollStatsScoring()</code> - creates lags and moving average features for a single record (along with the time between vars)
* <code>CreateCalendarVariables()</code> - creates numeric features identifying various time units based on date columns
* <code>CreateHolidayVariables()</code> - creates count features based on the specified holiday groups you want to track and the date columns you supply
* <code>AutoHierarchicalFourier()</code> - creates fourier pairs, by group, in paralell, for group variables and their interactions
* <code>DifferenceData()</code> - differencing of the target variable for single series and panel data
###### **Optimal transformations:** the target variable along with the associated lags and moving average features were transformed. This is really useful for regression models with categorical features that have associated target values that significantly differ from each other. The transformation options that are tested (using a Pearson test for normality) include:
* YeoJohnson
* BoxCox
* Log
* LogPlus1
* Sqrt
* arcsinh
* Identity
* arcsin(sqrt(x)): proportion data only
* logit(x): proportion data only
###### The functions used to create these and generate them for scoring models come from RemixAutoML:
* <code>AutoTransformationCreate()</code>
* <code>AutoTransformationScore()</code>
###### **Models:** there are four CARMA functions and each use a different algorithm for the model fitting. The models used to fit the time series data come from RemixAutoML and include:
* <code>AutoCatBoostRegression()</code>
* <code>AutoXGBoostRegression()</code>
* <code>AutoH2oDRFRegression()</code>
* <code>AutoH2oGBMRegression()</code>
* <code>AutoH2oGLMRegression()</code>
* <code>AutoH2oGAMRegression()</code>
* <code>AutoH2oAutoMLRegression()</code>
###### **GPU:** With the CatBoost and XGBoost functions, you can build the models utilizing GPU (I run them with a GeForce 1080ti) which results in an average 10x speedup in model training time (compared to running on CPU with 8 threads).
###### **Data partitioning:** for creating the training, validation, and test data, the CARMA functions utilize the <code>AutoDataPartition()</code> function and utilizes the "timeseries" option for the PartitionType argument which ensures that the train data reflects the furthest points back in time, followed by the validation data, and then the test data which is the most recent in time.
###### **Forecasting:** Once the regression model is built, the forecast process replicates the ARIMA process. Once a single step-ahead forecast is made, the lags and moving average features are updated based on the predicted values from scoring the model. Next, the rest of the other features are updated. Then the next forecast step is made, rinse and repeat for remaining forecasting steps. This process utilizes the RemixAutoML functions:
* <code>AutoCatBoostScoring()</code>
* <code>AutoXGBoostScoring()</code>
* <code>AutoH2oMLScoring()</code>
</p>
</details>
<h3><strong>AutoBanditSarima()</strong></h3>
<details><summary>Code Example</summary>
<p>
```

data

`AutoBanditSarima()`

is the newest weapon in the time series arsenal. This is the highest performing single series time series model in the package. The entire arima parameter space is divided up into blocks that are increasing in complexity of parameter settings. The multi-armed bandit will determine which parameter block to sample from more frequently based on which one is performing better than the others. The underlying bandit algorithm is the randomized probability matching algorithm found in the **bandit** package. I had to write a slight variation of it to allow for tweaking the number of intervals used in computing the integrals that result in the probabilities used for sampling. The evaluation is different from what exists today - you need to specify a weighting to use so that both the training metrics and validation metrics are used in calculating the best model. The user can specify 0% or 100% to go with just the one measure of their choice as well. The function returns a list with data.table of the forecasts and prediction inverals and the other item in the list is the Performance Grid results so you can see how every model tested performed.

Same as AutoBanditArima except it uses the forecast::nnetar model behind the scenes.

AutoTBATS uses forecast::tbats behind the scenes. It just runs through all the parameter settings and builds each model and returns the same list as the other two above.

AutoETS uses forecast::ets behind the scenes. It just runs through all the parameter settings and builds each model and returns the same list as the other two above.

AutoArfima uses forecast::arfima behind the scenes. It just runs through all the parameter settings and builds each model and returns the same list as the other two above.

`AutoTS()`

- Save model and xregs to file if a path is supplied
- Returns a list containing
- A data.table object with a date column and the forecasted values
- The model evaluation results
- The champion model for later use if desired
- The name of the champion model
- A time series ggplot with historical values and forecasted values with optional 80% and 95% prediction intervals

- The models tested internally include:
- DSHW: Double Seasonal Holt-Winters
- ARFIMA: Auto Regressive Fractional Integrated Moving Average
- ARIMA: Auto Regressive Integrated Moving Average with specified max lags, seasonal lags, moving averages, and seasonal moving averages
- ETS: Additive and Multiplicative Exponential Smoothing and Holt-Winters
- NNetar: Auto Regressive Neural Network models automatically compares models with 1 lag or 1 seasonal lag compared to models with up to N lags and N seasonal lags
- TBATS: Exponential smoothing state space model with Box-Cox transformation, ARMA errors, Trend and Seasonal components
- TSLM: Time Series Linear Model - builds a linear model with trend and season components extracted from the data

For each of the models tested internally, several aspects should be noted:

Optimal Box-Cox transformations are used in every run where data is strictly positive. The optimal transformation could also be "no transformation".

Four different treatments are tested for each model:

- user-specified time frequency + no historical series smoothing & imputation
- model-based time frequency + no historical smoothing and imputation
- user-specified time frequency + historical series smoothing & imputation
- model-based time frequency + historical smoothing & imputation

You can specify MaxFourierPairs to test out if adding Fourier term regressors can increase forecast accuracy. The Fourier terms will be applied to the ARIMA and NNetar models only.

For the ARIMA, ARFIMA, and TBATS, any number of lags and moving averages along with up to 1 seasonal lags and seasonal moving averages can be used (selection based on a stepwise procedure)

For the Double Seasonal Holt-Winters model, alpha, beta, gamma, omega, and phi are determined using least-squares and the forecasts are adjusted using an AR(1) model for the errors

The Exponential Smoothing State-Space model runs through an automatic selection of the error type, trend type, and season type, with the options being "none", "additive", and "multiplicative", along with testing of damped vs. non-damped trend (either additive or multiplicative), and alpha, beta, and phi are estimated

The neural network is setup to test out every combination of lags and seasonal lags and the model with the best holdout score is selected

The TBATS model utilizes any number of lags and moving averages for the errors, damped trend vs. non-damped trend are tested, trend vs. non-trend are also tested, and the model utilizes parallel processing for efficient run times

The TSLM model utilizes a simple time trend and season depending on the frequency of the data

`TimeSeriesFill()`

is a function that will zero pad (currently only zero pad) a time series data set (not transactional data). There are four ways to use this function:
Choose from:
* maxmax - Fill from the absolute min date to the absolute max date (single series and panel data)
* minmax - Fill from the max date of the min set to the absolute max date (panel data)
* maxmin - Fill from the absolute min date to the min of the max dates (panel data)
* minmin - Fill from the max date of the min dates to the min date of the max dates (panel data)

`ContinuousTimeDataGenerator()`

is for frequency and size data sets. This function generates count and size data sets for intermittent demand forecasting, using the methods in this package.

`AutoCatBoostSizeFreqDist()`

is for building size and frequency predictive distributions via quantile regressions. Size (or severity) and frequency (or count) quantile regressions are build and you supply the actual percentiles you want predicted. Use this with the `ID_SingleLevelGibbsSampler()`

function to simulate from the joint distribution.

`AutoH2oGBMSizeFreqDist()`

is for building size and frequency predictive distributions via quantile regressions. Size (or severity) and frequency (or count) quantile regressions are build and you supply the actual percentiles you want predicted. Use this with the `ID_SingleLevelGibbsSampler()`

function to simulate from the joint distribution.

`AutoCatBoostFreqSizeScoring()`

is for scoring the models build with `AutoCatBoostSizeFreqDist()`

. It will return the predicted values for every quantile model for both distributions for 1 to the max forecast periods you provided to build the scoring data.

`AutoH2oGBMFreqSizeScoring()`

is for scoring the models build with `AutoH2oGBMSizeFreqDist()`

. It will return the predicted values for every quantile model for both distributions for 1 to the max forecast periods you provided to build the scoring data.

`AutoRecomDataCreate()`

automatically creates your binary ratings matix from transaction data

`AutoRecommender()`

automated collaborative filtering modeling where each model below competes against one another for top performance

- RandomItems
- PopularItems
- UserBasedCF
- ItemBasedCF
- AssociationRules

`AutoRecommenderScoring()`

automatically score a recommender model from AutoRecommender()

`AutoMarketBasketModel()`

is a function that runs a market basket analysis automatically. It will convert your data, run the algorithm, and generate the recommended items. On top of that, it includes additional significance values not provided by the source pacakge.

`H2oAutoencoder()`

Use for dimension reduction and anomaly detection

`H2oIsolationForest()`

automatically identifies anomalous data records via Isolation Forests from H2O.

`AutoKMeans()`

This function builds a generalized low rank model followed by KMeans. (Possible cross with Feature Engineering) Generate a column with a cluster identifier based on a grid tuned (optional) generalized low rank model and a grid tuned (optimal) K-Optimal searching K-Means algorithm

`ResidualOutliers()`

Generate residual outliers from time series modeling. (Cross with Feature Engineering) Utilize tsoutliers to indicate outliers within a time series data set

`GenTSAnomVars()`

generates time series anomaly variables. (Cross with Feature Engineering) Create indicator variables (high, low) along with cumulative anomaly rates (high, low) based on control limits methodology over a max of two grouping variables and a date variable (effectively a rolling GLM).

`AutoDataDictionary()`

will pull back data dictionary data from a sql server data warehouse and run queries to pull in data to R. There are several data dictionary types that can be returned, such as returning every table that exists along with every column with metadata information. Another good one is to pull back all tables and their counterparts that can be used in joins, along with the joining sql.

`SQL_Server_DBConnection()`

Create a connect with sql server

`SQL_Query_Push()`

Push data to a sql server warehouse

`SQL_Query()`

Query a sql server table

`SQL_ClearTable()`

Deletes all rows of a sql server table

`SQL_DropTable()`

Removes a sql server table

`SQL_SaveTable()`

Write a sql server table

`SQL_UpdateTable()`

Update a sql server table

`SQL_Server_BulkPull()`

Query a sql server table using bulk copy process

`SQL_Server_BulkPush()`

Write to a sql server table using bulk copy process

`AutoWordFreq()`

creates a word frequency data.table and a word cloud

`ProblematicFeatures()`

identifies columns that have either little to no variance, categorical variables with extremely high cardinality, too many NA's, too many zeros, or too high of a skew.

`RemixTheme()`

is a specific font, set of colors, and style for plots.

`ChartTheme()`

is a specific font, set of colors, and style for plots.

`multiplot()`

is useful for displaying multiple plots in a single pane. I've never had luck using grid so I just use this instead.

`FakeDataGenerator()`

I use this to create fake data for the examples in the function help files