View source: R/AutoH2oGLMMultiClass.R
AutoH2oGLMMultiClass | R Documentation |
AutoH2oGLMMultiClass is an automated H2O modeling framework with grid-tuning and model evaluation that runs a variety of steps. First, a stratified sampling (by the target variable) is done to create train and validation sets. Then, the function will run a random grid tune over N number of models and find which model is the best (a default model is always included in that set). Once the model is identified and built, several other outputs are generated: validation data with predictions, evaluation metrics, confusion matrix, and variable importance.
AutoH2oGLMMultiClass(
OutputSelection = c("EvalMetrics", "Score_TrainData"),
data = NULL,
TrainOnFull = FALSE,
ValidationData = NULL,
TestData = NULL,
TargetColumnName = NULL,
FeatureColNames = NULL,
RandomColNumbers = NULL,
InteractionColNumbers = NULL,
WeightsColumn = NULL,
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),
ModelID = "FirstModel",
ReturnModelObjects = TRUE,
model_path = NULL,
metadata_path = NULL,
DebugMode = FALSE,
SaveModelObjects = FALSE,
SaveInfoToPDF = FALSE,
IfSaveModel = "mojo",
H2OShutdown = TRUE,
H2OStartUp = TRUE,
MaxModelsInGrid = 2,
NumOfParDepPlots = 3,
GridTune = FALSE,
GridStrategy = "Cartesian",
StoppingRounds = 10,
MaxRunTimeSecs = 3600 * 24 * 7,
Distribution = "multinomial",
Link = "family_default",
eval_metric = "logloss",
RandomDistribution = NULL,
RandomLink = NULL,
Solver = "AUTO",
Alpha = 0.5,
Lambda = NULL,
LambdaSearch = FALSE,
NLambdas = -1,
Standardize = TRUE,
RemoveCollinearColumns = FALSE,
InterceptInclude = TRUE,
NonNegativeCoefficients = FALSE
)
OutputSelection |
You can select what type of output you want returned. Choose from c("EvalMetrics", "Score_TrainData") |
data |
This is your data set for training and testing your model |
TrainOnFull |
Set to TRUE to train on full data |
ValidationData |
This is your holdout data set used in modeling either refine your hyperparameters. |
TestData |
This is your holdout data set. Catboost using both training and validation data in the training process so you should evaluate out of sample performance with this data set. |
TargetColumnName |
Either supply the target column name OR the column number where the target is located (but not mixed types). |
FeatureColNames |
Either supply the feature column names OR the column number where the target is located (but not mixed types) |
RandomColNumbers |
Random effects column number indicies. You can also pass character names of the columns. |
InteractionColNumbers |
Column numbers of the features you want to be pairwise interacted |
WeightsColumn |
Column name of a weights column |
MaxMem |
Set the maximum amount of memory you'd like to dedicate to the model run. E.g. "32G" |
NThreads |
Set the number of threads you want to dedicate to the model building |
ModelID |
A character string to name your model and output |
ReturnModelObjects |
Set to TRUE to output all modeling objects (E.g. plots and evaluation metrics) |
model_path |
A character string of your path file to where you want your output saved |
metadata_path |
A character string of your path file to where you want your model evaluation output saved. If left NULL, all output will be saved to model_path. |
DebugMode |
Set to TRUE to see a printout of each step |
SaveModelObjects |
Set to TRUE to return all modeling objects to your environment |
SaveInfoToPDF |
Set to TRUE to save insights to PDF |
IfSaveModel |
Set to "mojo" to save a mojo file, otherwise "standard" to save a regular H2O model object |
H2OShutdown |
Set to TRUE to shutdown H2O inside the function |
H2OStartUp |
Defaults to TRUE which means H2O will be started inside the function |
MaxModelsInGrid |
Number of models to test from grid options (1080 total possible options) |
NumOfParDepPlots |
Tell the function the number of partial dependence calibration plots you want to create. Calibration boxplots will only be created for numerical features (not dummy variables) |
GridTune |
Set to TRUE to run a grid tuning procedure. Set a number in MaxModelsInGrid to tell the procedure how many models you want to test. |
GridStrategy |
"RandomDiscrete" or "Cartesian" |
StoppingRounds |
Iterations in grid tuning |
MaxRunTimeSecs |
Max run time in seconds |
Distribution |
"multinomial" |
Link |
"family_default" |
eval_metric |
This is the metric used to identify best grid tuned model. Choose from "logloss" |
RandomDistribution |
Random effects family. Defaults NULL, otherwise it will run a hierarchical glm |
RandomLink |
Random effects link. Defaults NULL, otherwise it will run a hierarchical glm |
Solver |
Default "AUTO". Options include "IRLSM", "L_BFGS", "COORDINATE_DESCENT_NAIVE", "COORDINATE_DESCENT", "GRADIENT_DESCENT_LH", "GRADIENT_DESCENT_SQERR" |
Alpha |
Default 0.5 Otherwise supply a value between 0 and 1. 1 is equivalent to Lasso regression. 0 is equivalent to Ridge regression. Inbetween for a blend of the two. |
Lambda |
Default NULL. Regularization strength. |
LambdaSearch |
Default FALSE. |
NLambdas |
Default -1 |
Standardize |
Default TRUE. Standardize numerical columns |
RemoveCollinearColumns |
Default FALSE. Removes some of the linearly dependent columns |
InterceptInclude |
Default TRUE |
NonNegativeCoefficients |
Default FALSE |
Saves to file and returned in list: VariableImportance.csv, Model, ValidationData.csv, EvaluationMetrics.csv, GridCollect, and GridList
Adrian Antico
Other Automated Supervised Learning - Multiclass Classification:
AutoCatBoostMultiClass()
,
AutoH2oDRFMultiClass()
,
AutoH2oGAMMultiClass()
,
AutoH2oGBMMultiClass()
,
AutoH2oMLMultiClass()
,
AutoXGBoostMultiClass()
# Create some dummy correlated data with numeric and categorical features
data <- AutoQuant::FakeDataGenerator(
Correlation = 0.85,
N = 1000L,
ID = 2L,
ZIP = 0L,
AddDate = FALSE,
Classification = FALSE,
MultiClass = TRUE)
# Run function
TestModel <- AutoQuant::AutoH2oGLMMultiClass(
# Compute management
OutputSelection = c("EvalMetrics", "Score_TrainData"),
MaxMem = {gc();paste0(as.character(floor(as.numeric(system("awk '/MemFree/ {print $2}' /proc/meminfo", intern=TRUE)) / 1000000)),"G")},
NThreads = max(1, parallel::detectCores()-2),
H2OShutdown = TRUE,
H2OStartUp = TRUE,
IfSaveModel = "mojo",
# Model evaluation:
eval_metric = "logloss",
NumOfParDepPlots = 3,
# Metadata arguments:
model_path = NULL,
metadata_path = NULL,
ModelID = "FirstModel",
ReturnModelObjects = TRUE,
SaveModelObjects = FALSE,
SaveInfoToPDF = FALSE,
DebugMode = FALSE,
# Data arguments:
data = data,
TrainOnFull = FALSE,
ValidationData = NULL,
TestData = NULL,
TargetColumnName = "Adrian",
FeatureColNames = names(data)[!names(data) %in% c("IDcol_1", "IDcol_2","Adrian")],
RandomColNumbers = NULL,
InteractionColNumbers = NULL,
WeightsColumn = NULL,
# Model args
GridTune = FALSE,
GridStrategy = "Cartesian",
StoppingRounds = 10,
MaxRunTimeSecs = 3600 * 24 * 7,
MaxModelsInGrid = 10,
Distribution = "multinomial",
Link = "family_default",
RandomDistribution = NULL,
RandomLink = NULL,
Solver = "AUTO",
Alpha = 0.5,
Lambda = NULL,
LambdaSearch = FALSE,
NLambdas = -1,
Standardize = TRUE,
RemoveCollinearColumns = FALSE,
InterceptInclude = TRUE,
NonNegativeCoefficients = FALSE)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.