Goal is to automate building and tuning a classification model to predict employee attrition, using the h2o::h2o.automl.

Set up

Import data

Import the cleaned data from Module 7.

library(h2o)
## Warning: package 'h2o' was built under R version 4.3.3
## 
## ----------------------------------------------------------------------
## 
## Your next step is to start H2O:
##     > h2o.init()
## 
## For H2O package documentation, ask for help:
##     > ??h2o
## 
## After starting H2O, you can use the Web UI at http://localhost:54321
## For more information visit https://docs.h2o.ai
## 
## ----------------------------------------------------------------------
## 
## Attaching package: 'h2o'
## The following objects are masked from 'package:stats':
## 
##     cor, sd, var
## The following objects are masked from 'package:base':
## 
##     %*%, %in%, &&, ||, apply, as.factor, as.numeric, colnames,
##     colnames<-, ifelse, is.character, is.factor, is.numeric, log,
##     log10, log1p, log2, round, signif, trunc
library(tidyverse)
## Warning: package 'ggplot2' was built under R version 4.3.3
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.4     ✔ readr     2.1.5
## ✔ forcats   1.0.0     ✔ stringr   1.5.1
## ✔ ggplot2   3.5.1     ✔ tibble    3.2.1
## ✔ lubridate 1.9.3     ✔ tidyr     1.3.1
## ✔ purrr     1.0.2
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ lubridate::day()   masks h2o::day()
## ✖ dplyr::filter()    masks stats::filter()
## ✖ lubridate::hour()  masks h2o::hour()
## ✖ dplyr::lag()       masks stats::lag()
## ✖ lubridate::month() masks h2o::month()
## ✖ lubridate::week()  masks h2o::week()
## ✖ lubridate::year()  masks h2o::year()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
library(tidymodels)
## Warning: package 'tidymodels' was built under R version 4.3.3
## ── Attaching packages ────────────────────────────────────── tidymodels 1.2.0 ──
## ✔ broom        1.0.5     ✔ rsample      1.2.1
## ✔ dials        1.3.0     ✔ tune         1.2.1
## ✔ infer        1.0.7     ✔ workflows    1.1.4
## ✔ modeldata    1.4.0     ✔ workflowsets 1.1.0
## ✔ parsnip      1.2.1     ✔ yardstick    1.3.1
## ✔ recipes      1.1.0
## Warning: package 'dials' was built under R version 4.3.3
## Warning: package 'infer' was built under R version 4.3.3
## Warning: package 'modeldata' was built under R version 4.3.3
## Warning: package 'parsnip' was built under R version 4.3.3
## Warning: package 'recipes' was built under R version 4.3.3
## Warning: package 'rsample' was built under R version 4.3.3
## Warning: package 'tune' was built under R version 4.3.3
## Warning: package 'workflows' was built under R version 4.3.3
## Warning: package 'workflowsets' was built under R version 4.3.3
## Warning: package 'yardstick' was built under R version 4.3.3
## ── Conflicts ───────────────────────────────────────── tidymodels_conflicts() ──
## ✖ scales::discard() masks purrr::discard()
## ✖ dplyr::filter()   masks stats::filter()
## ✖ recipes::fixed()  masks stringr::fixed()
## ✖ dplyr::lag()      masks stats::lag()
## ✖ yardstick::spec() masks readr::spec()
## ✖ recipes::step()   masks stats::step()
## • Learn how to get started at https://www.tidymodels.org/start/
library(tidyquant)
## Loading required package: PerformanceAnalytics
## Loading required package: xts
## Loading required package: zoo
## 
## Attaching package: 'zoo'
## 
## The following objects are masked from 'package:base':
## 
##     as.Date, as.Date.numeric
## 
## 
## ######################### Warning from 'xts' package ##########################
## #                                                                             #
## # The dplyr lag() function breaks how base R's lag() function is supposed to  #
## # work, which breaks lag(my_xts). Calls to lag(my_xts) that you type or       #
## # source() into this session won't work correctly.                            #
## #                                                                             #
## # Use stats::lag() to make sure you're not using dplyr::lag(), or you can add #
## # conflictRules('dplyr', exclude = 'lag') to your .Rprofile to stop           #
## # dplyr from breaking base R's lag() function.                                #
## #                                                                             #
## # Code in packages is not affected. It's protected by R's namespace mechanism #
## # Set `options(xts.warn_dplyr_breaks_lag = FALSE)` to suppress this warning.  #
## #                                                                             #
## ###############################################################################
## 
## Attaching package: 'xts'
## 
## The following objects are masked from 'package:dplyr':
## 
##     first, last
## 
## 
## Attaching package: 'PerformanceAnalytics'
## 
## The following object is masked from 'package:graphics':
## 
##     legend
## 
## Loading required package: quantmod
## Loading required package: TTR
## 
## Attaching package: 'TTR'
## 
## The following object is masked from 'package:dials':
## 
##     momentum
## 
## Registered S3 method overwritten by 'quantmod':
##   method            from
##   as.zoo.data.frame zoo
data <- read_csv("../00_data/data_wrangled/data_clean.csv") %>%
    
    # h2o requires all variables to be either numeric or factors
    mutate(across(where(is.character), factor))
## Rows: 1470 Columns: 34
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (9): Attrition, BusinessTravel, Department, EducationField, Gender, Job...
## dbl (24): Age, DailyRate, DistanceFromHome, Education, EmployeeNumber, Envir...
## lgl  (1): Attrition == "YES"
## 
## ℹ Use `spec()` to retrieve the full column specification for this data.
## ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Split data

set.seed(1234)

data_split <- initial_split(data, strata = "Attrition")
train_tbl <- training(data_split)
test_tbl <- testing(data_split)

Recipes

recipe_obj <- recipe(Attrition ~ ., data = train_tbl) %>%
    
    # Remove zero variance variables
    step_zv(all_predictors()) 

Model

# Initialize h2o
h2o.init()
## 
## H2O is not running yet, starting it now...
## 
## Note:  In case of errors look at the following log files:
##     C:\Users\nilss\AppData\Local\Temp\RtmpgNRzWY\file701c333c7f20/h2o_nilss_started_from_r.out
##     C:\Users\nilss\AppData\Local\Temp\RtmpgNRzWY\file701c507f22d/h2o_nilss_started_from_r.err
## 
## 
## Starting H2O JVM and connecting:  Connection successful!
## 
## R is connected to the H2O cluster: 
##     H2O cluster uptime:         4 seconds 467 milliseconds 
##     H2O cluster timezone:       America/New_York 
##     H2O data parsing timezone:  UTC 
##     H2O cluster version:        3.44.0.3 
##     H2O cluster version age:    11 months and 15 days 
##     H2O cluster name:           H2O_started_from_R_nilss_fhp551 
##     H2O cluster total nodes:    1 
##     H2O cluster total memory:   3.92 GB 
##     H2O cluster total cores:    8 
##     H2O cluster allowed cores:  8 
##     H2O cluster healthy:        TRUE 
##     H2O Connection ip:          localhost 
##     H2O Connection port:        54321 
##     H2O Connection proxy:       NA 
##     H2O Internal Security:      FALSE 
##     R Version:                  R version 4.3.2 (2023-10-31 ucrt)
## Warning in h2o.clusterInfo(): 
## Your H2O cluster version is (11 months and 15 days) old. There may be a newer version available.
## Please download and install the latest version from: https://h2o-release.s3.amazonaws.com/h2o/latest_stable.html
split.h2o <- h2o.splitFrame(as.h2o(train_tbl), ratio = c(0.85), seed = 2345)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
train_h2o <- split.h2o[[1]]
valid_h2o <- split.h2o[[2]]
test_h2o <- as.h2o(test_tbl)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
y <- "Attrition"
x <- setdiff(names(train_tbl), y)

models_h2o <-h2o.automl(
    x = x, 
    y = y, 
    training_frame    = train_h2o, 
    validation_frame  = valid_h2o, 
    leaderboard_frame = test_h2o, 
    # max_runtime_secs  = 30, 
    max_models        = 10,
    exclude_algos     = "DeepLearning",
    nfolds            = 5, 
    seed              = 3456 
)
## 
  |                                                                            
  |                                                                      |   0%
## 15:52:58.739: User specified a validation frame with cross-validation still enabled. Please note that the models will still be validated using cross-validation only, the validation frame will be used to provide purely informative validation metrics on the trained models.
## 15:52:58.750: AutoML: XGBoost is not available; skipping it.
  |                                                                            
  |=                                                                     |   2%
## 15:53:03.587: GLM_1_AutoML_1_20241206_155258 [GLM def_1] failed: java.lang.ArrayIndexOutOfBoundsException: Index 55 out of bounds for length 55
  |                                                                            
  |=====                                                                 |   8%
  |                                                                            
  |=========                                                             |  12%
  |                                                                            
  |===============                                                       |  21%
  |                                                                            
  |====================                                                  |  29%
  |                                                                            
  |=======================                                               |  33%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |======================================================================| 100%

Examine the output of h2o.automl

models_h2o %>% typeof() 
## [1] "S4"
models_h2o %>% slotNames()
## [1] "project_name"   "leader"         "leaderboard"    "event_log"     
## [5] "modeling_steps" "training_info"
models_h2o@leaderboard
##                                      model_id mean_per_class_error   logloss
## 1              GBM_3_AutoML_1_20241206_155258            0.2231392 0.3855270
## 2              GBM_5_AutoML_1_20241206_155258            0.2286947 0.3891497
## 3              GBM_2_AutoML_1_20241206_155258            0.2408846 0.3901091
## 4 GBM_grid_1_AutoML_1_20241206_155258_model_2            0.2432039 0.4039940
## 5              GBM_4_AutoML_1_20241206_155258            0.2586300 0.3972846
## 6 GBM_grid_1_AutoML_1_20241206_155258_model_3            0.2643474 0.3742388
##        rmse       mse
## 1 0.3275068 0.1072607
## 2 0.3297208 0.1087158
## 3 0.3294560 0.1085413
## 4 0.3305562 0.1092674
## 5 0.3325350 0.1105795
## 6 0.3300422 0.1089278
## 
## [12 rows x 5 columns]
models_h2o@leader
## Model Details:
## ==============
## 
## H2OMultinomialModel: gbm
## Model ID:  GBM_3_AutoML_1_20241206_155258 
## Model Summary: 
##   number_of_trees number_of_internal_trees model_size_in_bytes min_depth
## 1              40                      120               65387         2
##   max_depth mean_depth min_leaves max_leaves mean_leaves
## 1         8    7.95000          3         50    38.74166
## 
## 
## H2OMultinomialMetrics: gbm
## ** Reported on training data. **
## 
## Training Set Metrics: 
## =====================
## 
## Extract training frame with `h2o.getFrame("AutoML_1_20241206_155258_training_RTMP_sid_82bd_5")`
## MSE: (Extract with `h2o.mse`) 0.008729674
## RMSE: (Extract with `h2o.rmse`) 0.09343272
## Logloss: (Extract with `h2o.logloss`) 0.06493089
## Mean Per-Class Error: 0.004444444
## AUC: (Extract with `h2o.auc`) NaN
## AUCPR: (Extract with `h2o.aucpr`) NaN
## R^2: (Extract with `h2o.r2`) 0.9356362
## Confusion Matrix: Extract with `h2o.confusionMatrix(<model>,train = TRUE)`)
## =========================================================================
## Confusion Matrix: Row labels: Actual class; Column labels: Predicted class
##           Attrition  No Yes  Error      Rate
## Attrition         1   0   0 0.0000 =   0 / 1
## No                0 788   0 0.0000 = 0 / 788
## Yes               0   2 148 0.0133 = 2 / 150
## Totals            1 790 148 0.0021 = 2 / 939
## 
## Hit Ratio Table: Extract with `h2o.hit_ratio_table(<model>,train = TRUE)`
## =======================================================================
## Top-3 Hit Ratios: 
##   k hit_ratio
## 1 1  0.997870
## 2 2  1.000000
## 3 3  1.000000
## 
## 
## 
## 
## H2OMultinomialMetrics: gbm
## ** Reported on validation data. **
## ** Validation metrics **
## 
## Validation Set Metrics: 
## =====================
## 
## Extract validation frame with `h2o.getFrame("RTMP_sid_82bd_7")`
## MSE: (Extract with `h2o.mse`) 0.101691
## RMSE: (Extract with `h2o.rmse`) 0.3188903
## Logloss: (Extract with `h2o.logloss`) 0.3544887
## Mean Per-Class Error: 0.2394699
## AUC: (Extract with `h2o.auc`) NaN
## AUCPR: (Extract with `h2o.aucpr`) NaN
## R^2: (Extract with `h2o.r2`) 0.264208
## Confusion Matrix: Extract with `h2o.confusionMatrix(<model>,valid = TRUE)`)
## =========================================================================
## Confusion Matrix: Row labels: Actual class; Column labels: Predicted class
##           Attrition  No Yes  Error       Rate
## Attrition         0   0   0     NA =    0 / 0
## No                0 134   2 0.0147 =  2 / 136
## Yes               0  19   8 0.7037 =  19 / 27
## Totals            0 153  10 0.1288 = 21 / 163
## 
## Hit Ratio Table: Extract with `h2o.hit_ratio_table(<model>,valid = TRUE)`
## =======================================================================
## Top-3 Hit Ratios: 
##   k hit_ratio
## 1 1  0.871166
## 2 2  1.000000
## 3 3  1.000000
## 
## 
## 
## 
## H2OMultinomialMetrics: gbm
## ** Reported on cross-validation data. **
## ** 5-fold cross-validation on training data (Metrics computed for combined holdout predictions) **
## 
## Cross-Validation Set Metrics: 
## =====================
## 
## Extract cross-validation frame with `h2o.getFrame("AutoML_1_20241206_155258_training_RTMP_sid_82bd_5")`
## MSE: (Extract with `h2o.mse`) 0.1092226
## RMSE: (Extract with `h2o.rmse`) 0.3304884
## Logloss: (Extract with `h2o.logloss`) 0.3815745
## Mean Per-Class Error: 0.5957642
## AUC: (Extract with `h2o.auc`) NaN
## AUCPR: (Extract with `h2o.aucpr`) NaN
## R^2: (Extract with `h2o.r2`) 0.194703
## Hit Ratio Table: Extract with `h2o.hit_ratio_table(<model>,xval = TRUE)`
## =======================================================================
## Top-3 Hit Ratios: 
##   k hit_ratio
## 1 1  0.863685
## 2 2  0.988285
## 3 3  1.000000
## 
## 
## 
## 
## Cross-Validation Metrics Summary: 
##                              mean       sd cv_1_valid cv_2_valid cv_3_valid
## accuracy                 0.861583 0.015252   0.856383   0.851064   0.851064
## auc                            NA 0.000000         NA         NA         NA
## err                      0.138417 0.015252   0.143617   0.148936   0.148936
## err_count               26.000000 2.915476  27.000000  28.000000  28.000000
## logloss                  0.393179 0.053331   0.466507   0.387792   0.423399
## max_per_class_error      0.826667 0.136219   1.000000   0.800000   0.900000
## mean_per_class_accuracy  0.671852 0.142794   0.422718   0.724894   0.697890
## mean_per_class_error     0.328148 0.142794   0.577282   0.275105   0.302110
## mse                      0.109744 0.014321   0.126312   0.112389   0.117847
## pr_auc                         NA 0.000000         NA         NA         NA
## r2                       0.191591 0.095742   0.104797   0.161965   0.121266
## rmse                     0.330694 0.021947   0.355404   0.335245   0.343289
##                         cv_4_valid cv_5_valid
## accuracy                  0.861702   0.887701
## auc                             NA         NA
## err                       0.138298   0.112299
## err_count                26.000000  21.000000
## logloss                   0.355043   0.333153
## max_per_class_error       0.800000   0.633333
## mean_per_class_accuracy   0.729114   0.784643
## mean_per_class_error      0.270886   0.215357
## mse                       0.103161   0.089010
## pr_auc                          NA         NA
## r2                        0.230777   0.339151
## rmse                      0.321187   0.298346
best_model <- models_h2o@leader

best_model
## Model Details:
## ==============
## 
## H2OMultinomialModel: gbm
## Model ID:  GBM_3_AutoML_1_20241206_155258 
## Model Summary: 
##   number_of_trees number_of_internal_trees model_size_in_bytes min_depth
## 1              40                      120               65387         2
##   max_depth mean_depth min_leaves max_leaves mean_leaves
## 1         8    7.95000          3         50    38.74166
## 
## 
## H2OMultinomialMetrics: gbm
## ** Reported on training data. **
## 
## Training Set Metrics: 
## =====================
## 
## Extract training frame with `h2o.getFrame("AutoML_1_20241206_155258_training_RTMP_sid_82bd_5")`
## MSE: (Extract with `h2o.mse`) 0.008729674
## RMSE: (Extract with `h2o.rmse`) 0.09343272
## Logloss: (Extract with `h2o.logloss`) 0.06493089
## Mean Per-Class Error: 0.004444444
## AUC: (Extract with `h2o.auc`) NaN
## AUCPR: (Extract with `h2o.aucpr`) NaN
## R^2: (Extract with `h2o.r2`) 0.9356362
## Confusion Matrix: Extract with `h2o.confusionMatrix(<model>,train = TRUE)`)
## =========================================================================
## Confusion Matrix: Row labels: Actual class; Column labels: Predicted class
##           Attrition  No Yes  Error      Rate
## Attrition         1   0   0 0.0000 =   0 / 1
## No                0 788   0 0.0000 = 0 / 788
## Yes               0   2 148 0.0133 = 2 / 150
## Totals            1 790 148 0.0021 = 2 / 939
## 
## Hit Ratio Table: Extract with `h2o.hit_ratio_table(<model>,train = TRUE)`
## =======================================================================
## Top-3 Hit Ratios: 
##   k hit_ratio
## 1 1  0.997870
## 2 2  1.000000
## 3 3  1.000000
## 
## 
## 
## 
## H2OMultinomialMetrics: gbm
## ** Reported on validation data. **
## ** Validation metrics **
## 
## Validation Set Metrics: 
## =====================
## 
## Extract validation frame with `h2o.getFrame("RTMP_sid_82bd_7")`
## MSE: (Extract with `h2o.mse`) 0.101691
## RMSE: (Extract with `h2o.rmse`) 0.3188903
## Logloss: (Extract with `h2o.logloss`) 0.3544887
## Mean Per-Class Error: 0.2394699
## AUC: (Extract with `h2o.auc`) NaN
## AUCPR: (Extract with `h2o.aucpr`) NaN
## R^2: (Extract with `h2o.r2`) 0.264208
## Confusion Matrix: Extract with `h2o.confusionMatrix(<model>,valid = TRUE)`)
## =========================================================================
## Confusion Matrix: Row labels: Actual class; Column labels: Predicted class
##           Attrition  No Yes  Error       Rate
## Attrition         0   0   0     NA =    0 / 0
## No                0 134   2 0.0147 =  2 / 136
## Yes               0  19   8 0.7037 =  19 / 27
## Totals            0 153  10 0.1288 = 21 / 163
## 
## Hit Ratio Table: Extract with `h2o.hit_ratio_table(<model>,valid = TRUE)`
## =======================================================================
## Top-3 Hit Ratios: 
##   k hit_ratio
## 1 1  0.871166
## 2 2  1.000000
## 3 3  1.000000
## 
## 
## 
## 
## H2OMultinomialMetrics: gbm
## ** Reported on cross-validation data. **
## ** 5-fold cross-validation on training data (Metrics computed for combined holdout predictions) **
## 
## Cross-Validation Set Metrics: 
## =====================
## 
## Extract cross-validation frame with `h2o.getFrame("AutoML_1_20241206_155258_training_RTMP_sid_82bd_5")`
## MSE: (Extract with `h2o.mse`) 0.1092226
## RMSE: (Extract with `h2o.rmse`) 0.3304884
## Logloss: (Extract with `h2o.logloss`) 0.3815745
## Mean Per-Class Error: 0.5957642
## AUC: (Extract with `h2o.auc`) NaN
## AUCPR: (Extract with `h2o.aucpr`) NaN
## R^2: (Extract with `h2o.r2`) 0.194703
## Hit Ratio Table: Extract with `h2o.hit_ratio_table(<model>,xval = TRUE)`
## =======================================================================
## Top-3 Hit Ratios: 
##   k hit_ratio
## 1 1  0.863685
## 2 2  0.988285
## 3 3  1.000000
## 
## 
## 
## 
## Cross-Validation Metrics Summary: 
##                              mean       sd cv_1_valid cv_2_valid cv_3_valid
## accuracy                 0.861583 0.015252   0.856383   0.851064   0.851064
## auc                            NA 0.000000         NA         NA         NA
## err                      0.138417 0.015252   0.143617   0.148936   0.148936
## err_count               26.000000 2.915476  27.000000  28.000000  28.000000
## logloss                  0.393179 0.053331   0.466507   0.387792   0.423399
## max_per_class_error      0.826667 0.136219   1.000000   0.800000   0.900000
## mean_per_class_accuracy  0.671852 0.142794   0.422718   0.724894   0.697890
## mean_per_class_error     0.328148 0.142794   0.577282   0.275105   0.302110
## mse                      0.109744 0.014321   0.126312   0.112389   0.117847
## pr_auc                         NA 0.000000         NA         NA         NA
## r2                       0.191591 0.095742   0.104797   0.161965   0.121266
## rmse                     0.330694 0.021947   0.355404   0.335245   0.343289
##                         cv_4_valid cv_5_valid
## accuracy                  0.861702   0.887701
## auc                             NA         NA
## err                       0.138298   0.112299
## err_count                26.000000  21.000000
## logloss                   0.355043   0.333153
## max_per_class_error       0.800000   0.633333
## mean_per_class_accuracy   0.729114   0.784643
## mean_per_class_error      0.270886   0.215357
## mse                       0.103161   0.089010
## pr_auc                          NA         NA
## r2                        0.230777   0.339151
## rmse                      0.321187   0.298346

Save and Load

#?h2o.getModel
#?h2o.saveModel
#?h2o.loadModel

#h2o.getModel(GBM_3_AutoML_1_20241121_121503) %>%
   # h2o.saveModel("h2o_models/")

#best_model <- h2o.loadModel(GBM_3_AutoML_1_20241121_121503)

Make predictions

predictions <- h2o.predict(best_model, newdata = test_h2o)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
predictions_tbl <- predictions %>%
    as_tibble()

# predictions_tbl %>%
    # bind_cols(test_tbl)

Evaluate model

?h2o.performance
## starting httpd help server ... done
performance_h2o <- h2o.performance(best_model, newdata = as.h2o(test_tbl))
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
typeof(performance_h2o)
## [1] "S4"
slotNames(performance_h2o)
## [1] "algorithm" "on_train"  "on_valid"  "on_xval"   "metrics"
performance_h2o@metrics
## $model
## $model$`__meta`
## $model$`__meta`$schema_version
## [1] 3
## 
## $model$`__meta`$schema_name
## [1] "ModelKeyV3"
## 
## $model$`__meta`$schema_type
## [1] "Key<Model>"
## 
## 
## $model$name
## [1] "GBM_3_AutoML_1_20241206_155258"
## 
## $model$type
## [1] "Key<Model>"
## 
## $model$URL
## [1] "/3/Models/GBM_3_AutoML_1_20241206_155258"
## 
## 
## $model_checksum
## [1] "3271101342999854048"
## 
## $frame
## $frame$name
## [1] "test_tbl_sid_82bd_119"
## 
## 
## $frame_checksum
## [1] "-5977174161532928616"
## 
## $description
## NULL
## 
## $scoring_time
## [1] 1.733519e+12
## 
## $predictions
## NULL
## 
## $MSE
## [1] 0.1072607
## 
## $RMSE
## [1] 0.3275068
## 
## $nobs
## [1] 370
## 
## $custom_metric_name
## NULL
## 
## $custom_metric_value
## [1] 0
## 
## $r2
## [1] 0.2307616
## 
## $hit_ratio_table
## Top-3 Hit Ratios: 
##   k hit_ratio
## 1 1  0.878378
## 2 2  1.000000
## 3 3  1.000000
## 
## $cm
## $cm$`__meta`
## $cm$`__meta`$schema_version
## [1] 3
## 
## $cm$`__meta`$schema_name
## [1] "ConfusionMatrixV3"
## 
## $cm$`__meta`$schema_type
## [1] "ConfusionMatrix"
## 
## 
## $cm$table
## Confusion Matrix: Row labels: Actual class; Column labels: Predicted class
##           Attrition  No Yes  Error       Rate
## Attrition         1   0   0 0.0000 =    0 / 1
## No                0 303   6 0.0194 =  6 / 309
## Yes               0  39  21 0.6500 =  39 / 60
## Totals            1 342  27 0.1216 = 45 / 370
## 
## 
## $logloss
## [1] 0.385527
## 
## $mean_per_class_error
## [1] 0.2231392
## 
## $AUC
## [1] "NaN"
## 
## $pr_auc
## [1] "NaN"
## 
## $multinomial_auc_table
## NULL
## 
## $multinomial_aucpr_table
## NULL
h2o.auc(performance_h2o)
## [1] "NaN"
h2o.confusionMatrix(performance_h2o)
## Confusion Matrix: Row labels: Actual class; Column labels: Predicted class
##           Attrition  No Yes  Error       Rate
## Attrition         1   0   0 0.0000 =    0 / 1
## No                0 303   6 0.0194 =  6 / 309
## Yes               0  39  21 0.6500 =  39 / 60
## Totals            1 342  27 0.1216 = 45 / 370