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
members <- readr::read_csv('https://raw.githubusercontent.com/rfordatascience/tidytuesday/master/data/2020/2020-09-22/members.csv') %>%
    
    mutate(across(where(is.character), factor))
## Rows: 76519 Columns: 21
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr (10): expedition_id, member_id, peak_id, peak_name, season, sex, citizen...
## dbl  (5): year, age, highpoint_metres, death_height_metres, injury_height_me...
## lgl  (6): hired, success, solo, oxygen_used, died, injured
## 
## ℹ 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(members, strata = "died")
train_tbl <- training(data_split)
test_tbl <- testing(data_split)

Recipes

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

Model

h2o.init()
##  Connection successful!
## 
## R is connected to the H2O cluster: 
##     H2O cluster uptime:         30 minutes 24 seconds 
##     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 1 day 
##     H2O cluster name:           H2O_started_from_R_eliza_vpd819 
##     H2O cluster total nodes:    1 
##     H2O cluster total memory:   3.17 GB 
##     H2O cluster total cores:    16 
##     H2O cluster allowed cores:  16 
##     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 1 day) 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), ratios = 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 <- "died"
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, 
    exclude_algos     = "DeepLearning",
    nfolds            = 5, 
    seed              = 3456   
)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |===                                                                   |   4%
## 21:39:24.59: 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.
## 21:39:24.67: AutoML: XGBoost is not available; skipping it.
  |                                                                            
  |=========                                                             |  13%
  |                                                                            
  |===============                                                       |  22%
  |                                                                            
  |======================                                                |  31%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |==================================                                    |  49%
  |                                                                            
  |=========================================                             |  58%
  |                                                                            
  |===============================================                       |  67%
  |                                                                            
  |=====================================================                 |  76%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |==================================================================    |  94%
  |                                                                            
  |======================================================================| 100%
models_h2o %>% typeof()
## [1] "S4"
models_h2o %>% slotNames()
## [1] "project_name"   "leader"         "leaderboard"    "event_log"     
## [5] "modeling_steps" "training_info"
models_h2o@leader
## Model Details:
## ==============
## 
## H2OBinomialModel: gbm
## Model ID:  GBM_1_AutoML_4_20241121_213924 
## Model Summary: 
##   number_of_trees number_of_internal_trees model_size_in_bytes min_depth
## 1              58                       58              185796         1
##   max_depth mean_depth min_leaves max_leaves mean_leaves
## 1        15   11.65517          2        208    88.72414
## 
## 
## H2OBinomialMetrics: gbm
## ** Reported on training data. **
## 
## MSE:  1.591511e-06
## RMSE:  0.001261551
## LogLoss:  8.547813e-05
## Mean Per-Class Error:  0
## AUC:  1
## AUCPR:  1
## Gini:  1
## R^2:  0.9998863
## 
## Confusion Matrix (vertical: actual; across: predicted) for F1-optimal threshold:
##        FALSE TRUE    Error      Rate
## FALSE  48023    0 0.000000  =0/48023
## TRUE       0  692 0.000000    =0/692
## Totals 48023  692 0.000000  =0/48715
## 
## Maximum Metrics: Maximum metrics at their respective thresholds
##                         metric threshold        value idx
## 1                       max f1  0.881735     1.000000 155
## 2                       max f2  0.881735     1.000000 155
## 3                 max f0point5  0.881735     1.000000 155
## 4                 max accuracy  0.881735     1.000000 155
## 5                max precision  0.999993     1.000000   0
## 6                   max recall  0.881735     1.000000 155
## 7              max specificity  0.999993     1.000000   0
## 8             max absolute_mcc  0.881735     1.000000 155
## 9   max min_per_class_accuracy  0.881735     1.000000 155
## 10 max mean_per_class_accuracy  0.881735     1.000000 155
## 11                     max tns  0.999993 48023.000000   0
## 12                     max fns  0.999993   689.000000   0
## 13                     max fps  0.000049 48023.000000 399
## 14                     max tps  0.881735   692.000000 155
## 15                     max tnr  0.999993     1.000000   0
## 16                     max fnr  0.999993     0.995665   0
## 17                     max fpr  0.000049     1.000000 399
## 18                     max tpr  0.881735     1.000000 155
## 
## Gains/Lift Table: Extract with `h2o.gainsLift(<model>, <data>)` or `h2o.gainsLift(<model>, valid=<T/F>, xval=<T/F>)`
## H2OBinomialMetrics: gbm
## ** Reported on validation data. **
## ** Validation metrics **
## 
## MSE:  5.933745e-06
## RMSE:  0.002435928
## LogLoss:  0.000103277
## Mean Per-Class Error:  0
## AUC:  1
## AUCPR:  1
## Gini:  1
## R^2:  0.9996365
## 
## Confusion Matrix (vertical: actual; across: predicted) for F1-optimal threshold:
##        FALSE TRUE    Error     Rate
## FALSE   8530    0 0.000000  =0/8530
## TRUE       0  144 0.000000   =0/144
## Totals  8530  144 0.000000  =0/8674
## 
## Maximum Metrics: Maximum metrics at their respective thresholds
##                         metric threshold       value idx
## 1                       max f1  0.836076    1.000000  99
## 2                       max f2  0.836076    1.000000  99
## 3                 max f0point5  0.836076    1.000000  99
## 4                 max accuracy  0.836076    1.000000  99
## 5                max precision  0.999996    1.000000   0
## 6                   max recall  0.836076    1.000000  99
## 7              max specificity  0.999996    1.000000   0
## 8             max absolute_mcc  0.836076    1.000000  99
## 9   max min_per_class_accuracy  0.836076    1.000000  99
## 10 max mean_per_class_accuracy  0.836076    1.000000  99
## 11                     max tns  0.999996 8530.000000   0
## 12                     max fns  0.999996  143.000000   0
## 13                     max fps  0.000048 8530.000000 399
## 14                     max tps  0.836076  144.000000  99
## 15                     max tnr  0.999996    1.000000   0
## 16                     max fnr  0.999996    0.993056   0
## 17                     max fpr  0.000048    1.000000 399
## 18                     max tpr  0.836076    1.000000  99
## 
## Gains/Lift Table: Extract with `h2o.gainsLift(<model>, <data>)` or `h2o.gainsLift(<model>, valid=<T/F>, xval=<T/F>)`
## H2OBinomialMetrics: gbm
## ** Reported on cross-validation data. **
## ** 5-fold cross-validation on training data (Metrics computed for combined holdout predictions) **
## 
## MSE:  0.0001997517
## RMSE:  0.01413335
## LogLoss:  0.001075555
## Mean Per-Class Error:  0
## AUC:  1
## AUCPR:  1
## Gini:  1
## R^2:  0.9857354
## 
## Confusion Matrix (vertical: actual; across: predicted) for F1-optimal threshold:
##        FALSE TRUE    Error      Rate
## FALSE  48023    0 0.000000  =0/48023
## TRUE       0  692 0.000000    =0/692
## Totals 48023  692 0.000000  =0/48715
## 
## Maximum Metrics: Maximum metrics at their respective thresholds
##                         metric threshold        value idx
## 1                       max f1  0.035777     1.000000 168
## 2                       max f2  0.035777     1.000000 168
## 3                 max f0point5  0.035777     1.000000 168
## 4                 max accuracy  0.035777     1.000000 168
## 5                max precision  0.999999     1.000000   0
## 6                   max recall  0.035777     1.000000 168
## 7              max specificity  0.999999     1.000000   0
## 8             max absolute_mcc  0.035777     1.000000 168
## 9   max min_per_class_accuracy  0.035777     1.000000 168
## 10 max mean_per_class_accuracy  0.035777     1.000000 168
## 11                     max tns  0.999999 48023.000000   0
## 12                     max fns  0.999999   642.000000   0
## 13                     max fps  0.000001 48023.000000 399
## 14                     max tps  0.035777   692.000000 168
## 15                     max tnr  0.999999     1.000000   0
## 16                     max fnr  0.999999     0.927746   0
## 17                     max fpr  0.000001     1.000000 399
## 18                     max tpr  0.035777     1.000000 168
## 
## Gains/Lift Table: Extract with `h2o.gainsLift(<model>, <data>)` or `h2o.gainsLift(<model>, valid=<T/F>, xval=<T/F>)`
## Cross-Validation Metrics Summary: 
##                              mean       sd cv_1_valid cv_2_valid cv_3_valid
## accuracy                 1.000000 0.000000   1.000000   1.000000   1.000000
## auc                      1.000000 0.000000   1.000000   1.000000   1.000000
## err                      0.000000 0.000000   0.000000   0.000000   0.000000
## err_count                0.000000 0.000000   0.000000   0.000000   0.000000
## f0point5                 1.000000 0.000000   1.000000   1.000000   1.000000
## f1                       1.000000 0.000000   1.000000   1.000000   1.000000
## f2                       1.000000 0.000000   1.000000   1.000000   1.000000
## lift_top_group          70.553345 3.681065  74.374050  69.099290  73.810610
## logloss                  0.001076 0.000929   0.001440   0.002457   0.000119
## max_per_class_error      0.000000 0.000000   0.000000   0.000000   0.000000
## mcc                      1.000000 0.000000   1.000000   1.000000   1.000000
## mean_per_class_accuracy  1.000000 0.000000   1.000000   1.000000   1.000000
## mean_per_class_error     0.000000 0.000000   0.000000   0.000000   0.000000
## mse                      0.000200 0.000137   0.000165   0.000381   0.000028
## pr_auc                   1.000000 0.000000   1.000000   1.000000   1.000000
## precision                1.000000 0.000000   1.000000   1.000000   1.000000
## r2                       0.985981 0.009361   0.987583   0.973291   0.997941
## recall                   1.000000 0.000000   1.000000   1.000000   1.000000
## rmse                     0.013260 0.005469   0.012834   0.019518   0.005245
## specificity              1.000000 0.000000   1.000000   1.000000   1.000000
##                         cv_4_valid cv_5_valid
## accuracy                  1.000000   1.000000
## auc                       1.000000   1.000000
## err                       0.000000   0.000000
## err_count                 0.000000   0.000000
## f0point5                  1.000000   1.000000
## f1                        1.000000   1.000000
## f2                        1.000000   1.000000
## lift_top_group           65.389260  70.093530
## logloss                   0.000984   0.000378
## max_per_class_error       0.000000   0.000000
## mcc                       1.000000   1.000000
## mean_per_class_accuracy   1.000000   1.000000
## mean_per_class_error      0.000000   0.000000
## mse                       0.000288   0.000138
## pr_auc                    1.000000   1.000000
## precision                 1.000000   1.000000
## r2                        0.980884   0.990206
## recall                    1.000000   1.000000
## rmse                      0.016967   0.011736
## specificity               1.000000   1.000000

Save and Load

#h2o.getModel("StackedEnsemble_BestOfFamily_1_AutoML_3_20241121_213355") %>%
 #   h2o.saveModel("C:/Users/eliza/Desktop/PSU_DAT3100/11_module13/h2o_models/")

best_model <- h2o.loadModel("C:\\Users\\eliza\\Desktop\\PSU_DAT3100\\11_module13\\h2o_models\\StackedEnsemble_BestOfFamily_1_AutoML_3_20241121_213355")

Make predictions

predictions <- h2o.predict(best_model, newdata = test_h2o)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
## Warning in doTryCatch(return(expr), name, parentenv, handler): Test/Validation
## dataset column 'expedition_id' has levels not trained on: ["AMAD00308",
## "AMAD02405", "AMAD07339", "AMAD11360", "AMAD11363", "AMAD12104", "AMAD12334",
## "AMAD13302", "AMAD17357", "AMAD98309", ...87 not listed..., "MANA16401",
## "MANA17102", "MANA17319", "MARD80301", "MERR11301", "MNSL14302", "PERI18401",
## "PUMO97303", "SNOW79301", "TUKU97103"]
## Warning in doTryCatch(return(expr), name, parentenv, handler): Test/Validation
## dataset column 'member_id' has levels not trained on: ["ACHN18301-09",
## "AMAD00102-05", "AMAD00104-06", "AMAD00109-02", "AMAD00112-01", "AMAD00301-05",
## "AMAD00308-01", "AMAD00311-02", "AMAD00313-05", "AMAD00314-02", ...4781 not
## listed..., "YALU75101-07", "YALU81102-08", "YALU81102-17", "YALU81102-22",
## "YALU84302-05", "YALU85101-01", "YALU85101-16", "YALU89301-09", "YALU91301-06",
## "YAUP17101-04"]
## Warning in doTryCatch(return(expr), name, parentenv, handler): Test/Validation
## dataset column 'peak_id' has levels not trained on: ["SNOW"]
## Warning in doTryCatch(return(expr), name, parentenv, handler): Test/Validation
## dataset column 'peak_name' has levels not trained on: ["Snow Peak"]
## Warning in doTryCatch(return(expr), name, parentenv, handler): Test/Validation
## dataset column 'citizenship' has levels not trained on: ["Canada/UK",
## "Chile/Sweden", "Netherlands/Switzerland", "Switzerland/Greece", "USA/Austria"]
## Warning in doTryCatch(return(expr), name, parentenv, handler): Test/Validation
## dataset column 'expedition_role' has levels not trained on: ["BBC Producer",
## "BC Manager & Cook", "BC Manager (C1 only)", "Climber/Research", "Dep Leader
## (admin)", "Deputy Ldr/Exp Mgr", "Deputy Leader (Xixa)", "Deputy Leader III",
## "Everest-Lhotse Climber", "Exp Doctor (S side)", ...8 not listed..., "Leader of
## KPNU Grp", "Leader/Adv BC Manager", "Leader?", "Logistics Supervisor", "Naike",
## "Sandrine Marie Rose", "Ski Team Leader", "Student Leader", "Video
## Photographer", "Wireless Operator"]
predictions_tbl <- predictions %>%
    as_tibble()

predictions_tbl %>%
    bind_cols(test_tbl)
## # A tibble: 19,130 × 24
##    predict FALSE.    TRUE. expedition_id member_id    peak_id peak_name   year
##    <fct>    <dbl>    <dbl> <fct>         <fct>        <fct>   <fct>      <dbl>
##  1 FALSE     1.00 2.75e-10 AMAD78301     AMAD78301-04 AMAD    Ama Dablam  1978
##  2 FALSE     1.00 3.07e-10 AMAD79101     AMAD79101-05 AMAD    Ama Dablam  1979
##  3 FALSE     1.00 3.81e-10 AMAD79101     AMAD79101-01 AMAD    Ama Dablam  1979
##  4 FALSE     1.00 3.66e-10 AMAD79101     AMAD79101-06 AMAD    Ama Dablam  1979
##  5 FALSE     1.00 3.77e-10 AMAD79101     AMAD79101-08 AMAD    Ama Dablam  1979
##  6 FALSE     1.00 2.96e-10 AMAD79101     AMAD79101-02 AMAD    Ama Dablam  1979
##  7 FALSE     1.00 2.99e-10 AMAD79101     AMAD79101-11 AMAD    Ama Dablam  1979
##  8 FALSE     1.00 2.99e-10 AMAD79101     AMAD79101-13 AMAD    Ama Dablam  1979
##  9 FALSE     1.00 3.77e-10 AMAD79101     AMAD79101-14 AMAD    Ama Dablam  1979
## 10 FALSE     1.00 3.14e-10 AMAD79301     AMAD79301-12 AMAD    Ama Dablam  1979
## # ℹ 19,120 more rows
## # ℹ 16 more variables: season <fct>, sex <fct>, age <dbl>, citizenship <fct>,
## #   expedition_role <fct>, hired <lgl>, highpoint_metres <dbl>, success <lgl>,
## #   solo <lgl>, oxygen_used <lgl>, died <lgl>, death_cause <fct>,
## #   death_height_metres <dbl>, injured <lgl>, injury_type <fct>,
## #   injury_height_metres <dbl>

Evaluate model

performance_h2o <- h2o.performance(best_model, newdata = test_h2o)
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] "StackedEnsemble_BestOfFamily_1_AutoML_3_20241121_213355"
## 
## $model$type
## [1] "Key<Model>"
## 
## $model$URL
## [1] "/3/Models/StackedEnsemble_BestOfFamily_1_AutoML_3_20241121_213355"
## 
## 
## $model_checksum
## [1] "-8897384442014169856"
## 
## $frame
## $frame$name
## [1] "test_tbl_sid_804c_3"
## 
## 
## $frame_checksum
## [1] 9.199332e+14
## 
## $description
## NULL
## 
## $scoring_time
## [1] 1.732243e+12
## 
## $predictions
## NULL
## 
## $MSE
## [1] 1.62542e-11
## 
## $RMSE
## [1] 4.03165e-06
## 
## $nobs
## [1] 19130
## 
## $custom_metric_name
## NULL
## 
## $custom_metric_value
## [1] 0
## 
## $r2
## [1] 1
## 
## $logloss
## [1] 6.758657e-08
## 
## $AUC
## [1] 1
## 
## $pr_auc
## [1] 1
## 
## $Gini
## [1] 1
## 
## $mean_per_class_error
## [1] 0
## 
## $domain
## [1] "FALSE" "TRUE" 
## 
## $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
##        FALSE TRUE  Error         Rate
## FALSE  18860    0 0.0000 = 0 / 18,860
## TRUE       0  270 0.0000 =    0 / 270
## Totals 18860  270 0.0000 = 0 / 19,130
## 
## 
## $thresholds_and_metric_scores
## Metrics for Thresholds: Binomial metrics as a function of classification thresholds
##   threshold       f1       f2 f0point5 accuracy precision   recall specificity
## 1  1.000000 1.000000 1.000000 1.000000 1.000000  1.000000 1.000000    1.000000
## 2  0.000538 0.998152 0.999260 0.997046 0.999948  0.996310 1.000000    0.999947
## 3  0.000071 0.996310 0.998521 0.994109 0.999895  0.992647 1.000000    0.999894
## 4  0.000052 0.994475 0.997783 0.991189 0.999843  0.989011 1.000000    0.999841
## 5  0.000052 0.992647 0.997046 0.988287 0.999791  0.985401 1.000000    0.999788
##   absolute_mcc min_per_class_accuracy mean_per_class_accuracy   tns fns fps tps
## 1     1.000000               1.000000                1.000000 18860   0   0 270
## 2     0.998127               0.999947                0.999973 18859   0   1 270
## 3     0.996264               0.999894                0.999947 18858   0   2 270
## 4     0.994411               0.999841                0.999920 18857   0   3 270
## 5     0.992569               0.999788                0.999894 18856   0   4 270
##        tnr      fnr      fpr      tpr idx
## 1 1.000000 0.000000 0.000000 1.000000   0
## 2 0.999947 0.000000 0.000053 1.000000   1
## 3 0.999894 0.000000 0.000106 1.000000   2
## 4 0.999841 0.000000 0.000159 1.000000   3
## 5 0.999788 0.000000 0.000212 1.000000   4
## 
## ---
##     threshold       f1       f2 f0point5 accuracy precision   recall
## 395  0.000000 0.031190 0.074491 0.019725 0.123210  0.015842 1.000000
## 396  0.000000 0.030193 0.072212 0.019087 0.093309  0.015328 1.000000
## 397  0.000000 0.029338 0.070254 0.018540 0.066074  0.014888 1.000000
## 398  0.000000 0.028653 0.068681 0.018103 0.043074  0.014535 1.000000
## 399  0.000000 0.028075 0.067352 0.017734 0.022791  0.014238 1.000000
## 400  0.000000 0.027835 0.066799 0.017580 0.014114  0.014114 1.000000
##     specificity absolute_mcc min_per_class_accuracy mean_per_class_accuracy
## 395    0.110657     0.041870               0.110657                0.555329
## 396    0.080329     0.035089               0.080329                0.540164
## 397    0.052704     0.028011               0.052704                0.526352
## 398    0.029374     0.020663               0.029374                0.514687
## 399    0.008802     0.011194               0.008802                0.504401
## 400    0.000000     0.000000               0.000000                0.500000
##      tns fns   fps tps      tnr      fnr      fpr      tpr idx
## 395 2087   0 16773 270 0.110657 0.000000 0.889343 1.000000 394
## 396 1515   0 17345 270 0.080329 0.000000 0.919671 1.000000 395
## 397  994   0 17866 270 0.052704 0.000000 0.947296 1.000000 396
## 398  554   0 18306 270 0.029374 0.000000 0.970626 1.000000 397
## 399  166   0 18694 270 0.008802 0.000000 0.991198 1.000000 398
## 400    0   0 18860 270 0.000000 0.000000 1.000000 1.000000 399
## 
## $max_criteria_and_metric_scores
## Maximum Metrics: Maximum metrics at their respective thresholds
##                         metric threshold        value idx
## 1                       max f1  1.000000     1.000000   0
## 2                       max f2  1.000000     1.000000   0
## 3                 max f0point5  1.000000     1.000000   0
## 4                 max accuracy  1.000000     1.000000   0
## 5                max precision  1.000000     1.000000   0
## 6                   max recall  1.000000     1.000000   0
## 7              max specificity  1.000000     1.000000   0
## 8             max absolute_mcc  1.000000     1.000000   0
## 9   max min_per_class_accuracy  1.000000     1.000000   0
## 10 max mean_per_class_accuracy  1.000000     1.000000   0
## 11                     max tns  1.000000 18860.000000   0
## 12                     max fns  1.000000     0.000000   0
## 13                     max fps  0.000000 18860.000000 399
## 14                     max tps  1.000000   270.000000   0
## 15                     max tnr  1.000000     1.000000   0
## 16                     max fnr  1.000000     0.000000   0
## 17                     max fpr  0.000000     1.000000 399
## 18                     max tpr  1.000000     1.000000   0
## 
## $gains_lift_table
## Gains/Lift Table: Avg response rate:  1.41 %, avg score:  1.41 %
##    group cumulative_data_fraction lower_threshold      lift cumulative_lift
## 1      1               0.01359122        1.000000 70.851852       70.851852
## 2      2               0.02002091        0.000000  5.760313       49.947781
## 3      3               0.03000523        0.000000  0.000000       33.327526
## 4      4               0.04004182        0.000000  0.000000       24.973890
## 5      5               0.05002614        0.000000  0.000000       19.989551
## 6      6               0.10000000        0.000000  0.000000       10.000000
## 7      7               0.15002614        0.000000  0.000000        6.665505
## 8      8               0.20000000        0.000000  0.000000        5.000000
## 9      9               0.30000000        0.000000  0.000000        3.333333
## 10    10               0.40005227        0.000000  0.000000        2.499673
## 11    11               0.50000000        0.000000  0.000000        2.000000
## 12    12               0.60000000        0.000000  0.000000        1.666667
## 13    13               0.70000000        0.000000  0.000000        1.428571
## 14    14               0.80000000        0.000000  0.000000        1.250000
## 15    15               0.90000000        0.000000  0.000000        1.111111
## 16    16               1.00000000        0.000000  0.000000        1.000000
##    response_rate    score cumulative_response_rate cumulative_score
## 1       1.000000 1.000000                 1.000000         1.000000
## 2       0.081301 0.081311                 0.704961         0.704964
## 3       0.000000 0.000000                 0.470383         0.470386
## 4       0.000000 0.000000                 0.352480         0.352482
## 5       0.000000 0.000000                 0.282132         0.282133
## 6       0.000000 0.000000                 0.141140         0.141140
## 7       0.000000 0.000000                 0.094077         0.094077
## 8       0.000000 0.000000                 0.070570         0.070570
## 9       0.000000 0.000000                 0.047047         0.047047
## 10      0.000000 0.000000                 0.035280         0.035280
## 11      0.000000 0.000000                 0.028228         0.028228
## 12      0.000000 0.000000                 0.023523         0.023523
## 13      0.000000 0.000000                 0.020163         0.020163
## 14      0.000000 0.000000                 0.017642         0.017643
## 15      0.000000 0.000000                 0.015682         0.015682
## 16      0.000000 0.000000                 0.014114         0.014114
##    capture_rate cumulative_capture_rate        gain cumulative_gain
## 1      0.962963                0.962963 6985.185185     6985.185185
## 2      0.037037                1.000000  476.031316     4894.778068
## 3      0.000000                1.000000 -100.000000     3232.752613
## 4      0.000000                1.000000 -100.000000     2397.389034
## 5      0.000000                1.000000 -100.000000     1898.955068
## 6      0.000000                1.000000 -100.000000      900.000000
## 7      0.000000                1.000000 -100.000000      566.550523
## 8      0.000000                1.000000 -100.000000      400.000000
## 9      0.000000                1.000000 -100.000000      233.333333
## 10     0.000000                1.000000 -100.000000      149.967333
## 11     0.000000                1.000000 -100.000000      100.000000
## 12     0.000000                1.000000 -100.000000       66.666667
## 13     0.000000                1.000000 -100.000000       42.857143
## 14     0.000000                1.000000 -100.000000       25.000000
## 15     0.000000                1.000000 -100.000000       11.111111
## 16     0.000000                1.000000 -100.000000        0.000000
##    kolmogorov_smirnov
## 1            0.962963
## 2            0.994008
## 3            0.983881
## 4            0.973701
## 5            0.963574
## 6            0.912884
## 7            0.862142
## 8            0.811453
## 9            0.710021
## 10           0.608537
## 11           0.507158
## 12           0.405726
## 13           0.304295
## 14           0.202863
## 15           0.101432
## 16           0.000000
## 
## $residual_deviance
## [1] 0.002585862
## 
## $null_deviance
## [1] 2837.674
## 
## $AIC
## [1] 6.002586
## 
## $loglikelihood
## [1] 0
## 
## $null_degrees_of_freedom
## [1] 19129
## 
## $residual_degrees_of_freedom
## [1] 19127
h2o.auc(performance_h2o)
## [1] 1
h2o.confusionMatrix(performance_h2o)
## Confusion Matrix (vertical: actual; across: predicted)  for max f1 @ threshold = 0.99999999999871:
##        FALSE TRUE    Error      Rate
## FALSE  18860    0 0.000000  =0/18860
## TRUE       0  270 0.000000    =0/270
## Totals 18860  270 0.000000  =0/19130
h2o.metric(performance_h2o)
## Metrics for Thresholds: Binomial metrics as a function of classification thresholds
##   threshold       f1       f2 f0point5 accuracy precision   recall specificity
## 1  1.000000 1.000000 1.000000 1.000000 1.000000  1.000000 1.000000    1.000000
## 2  0.000538 0.998152 0.999260 0.997046 0.999948  0.996310 1.000000    0.999947
## 3  0.000071 0.996310 0.998521 0.994109 0.999895  0.992647 1.000000    0.999894
## 4  0.000052 0.994475 0.997783 0.991189 0.999843  0.989011 1.000000    0.999841
## 5  0.000052 0.992647 0.997046 0.988287 0.999791  0.985401 1.000000    0.999788
##   absolute_mcc min_per_class_accuracy mean_per_class_accuracy   tns fns fps tps
## 1     1.000000               1.000000                1.000000 18860   0   0 270
## 2     0.998127               0.999947                0.999973 18859   0   1 270
## 3     0.996264               0.999894                0.999947 18858   0   2 270
## 4     0.994411               0.999841                0.999920 18857   0   3 270
## 5     0.992569               0.999788                0.999894 18856   0   4 270
##        tnr      fnr      fpr      tpr idx
## 1 1.000000 0.000000 0.000000 1.000000   0
## 2 0.999947 0.000000 0.000053 1.000000   1
## 3 0.999894 0.000000 0.000106 1.000000   2
## 4 0.999841 0.000000 0.000159 1.000000   3
## 5 0.999788 0.000000 0.000212 1.000000   4
## 
## ---
##     threshold       f1       f2 f0point5 accuracy precision   recall
## 395  0.000000 0.031190 0.074491 0.019725 0.123210  0.015842 1.000000
## 396  0.000000 0.030193 0.072212 0.019087 0.093309  0.015328 1.000000
## 397  0.000000 0.029338 0.070254 0.018540 0.066074  0.014888 1.000000
## 398  0.000000 0.028653 0.068681 0.018103 0.043074  0.014535 1.000000
## 399  0.000000 0.028075 0.067352 0.017734 0.022791  0.014238 1.000000
## 400  0.000000 0.027835 0.066799 0.017580 0.014114  0.014114 1.000000
##     specificity absolute_mcc min_per_class_accuracy mean_per_class_accuracy
## 395    0.110657     0.041870               0.110657                0.555329
## 396    0.080329     0.035089               0.080329                0.540164
## 397    0.052704     0.028011               0.052704                0.526352
## 398    0.029374     0.020663               0.029374                0.514687
## 399    0.008802     0.011194               0.008802                0.504401
## 400    0.000000     0.000000               0.000000                0.500000
##      tns fns   fps tps      tnr      fnr      fpr      tpr idx
## 395 2087   0 16773 270 0.110657 0.000000 0.889343 1.000000 394
## 396 1515   0 17345 270 0.080329 0.000000 0.919671 1.000000 395
## 397  994   0 17866 270 0.052704 0.000000 0.947296 1.000000 396
## 398  554   0 18306 270 0.029374 0.000000 0.970626 1.000000 397
## 399  166   0 18694 270 0.008802 0.000000 0.991198 1.000000 398
## 400    0   0 18860 270 0.000000 0.000000 1.000000 1.000000 399