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)
## 
## ----------------------------------------------------------------------
## 
## 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)
## ── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2
## ──
## ✔ ggplot2 3.4.4     ✔ purrr   1.0.2
## ✔ tibble  3.2.1     ✔ dplyr   1.1.4
## ✔ tidyr   1.3.0     ✔ stringr 1.5.0
## ✔ readr   2.1.3     ✔ forcats 1.0.0
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
library(tidymodels)
## ── Attaching packages ────────────────────────────────────── tidymodels 1.1.1 ──
## ✔ broom        1.0.5      ✔ rsample      1.2.0 
## ✔ dials        1.2.0      ✔ tune         1.1.2 
## ✔ infer        1.0.6      ✔ workflows    1.1.4 
## ✔ modeldata    1.3.0      ✔ workflowsets 1.0.1 
## ✔ parsnip      1.2.0      ✔ yardstick    1.2.0 
## ✔ recipes      1.0.10     
## ── 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()
## • Use suppressPackageStartupMessages() to eliminate package startup messages
library(tidyquant)
## Loading required package: lubridate
## 
## Attaching package: 'lubridate'
## 
## The following objects are masked from 'package:h2o':
## 
##     day, hour, month, week, year
## 
## The following objects are masked from 'package:base':
## 
##     date, intersect, setdiff, union
## 
## 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
## 
## 
## 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: 32
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (8): Attrition, BusinessTravel, Department, EducationField, Gender, Job...
## dbl (24): Age, DailyRate, DistanceFromHome, Education, EmployeeNumber, Envir...
## 
## ℹ 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 h20
h2o.init()
##  Connection successful!
## 
## R is connected to the H2O cluster: 
##     H2O cluster uptime:         4 days 18 hours 
##     H2O cluster timezone:       America/New_York 
##     H2O data parsing timezone:  UTC 
##     H2O cluster version:        3.44.0.3 
##     H2O cluster version age:    4 months and 9 days 
##     H2O cluster name:           H2O_started_from_R_stephenmorris_fhp551 
##     H2O cluster total nodes:    1 
##     H2O cluster total memory:   0.93 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.2.2 (2022-10-31)
## Warning in h2o.clusterInfo(): 
## Your H2O cluster version is (4 months and 9 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), 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 <- "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,
    nfolds  = 5,
    seed = 3456
)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |==                                                                    |   3%
## 11:02:18.692: 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.
  |                                                                            
  |=======                                                               |  10%
  |                                                                            
  |============                                                          |  17%
  |                                                                            
  |=================                                                     |  24%
  |                                                                            
  |=====================                                                 |  30%
  |                                                                            
  |==========================                                            |  37%
  |                                                                            
  |===============================                                       |  44%
  |                                                                            
  |===================================                                   |  51%
  |                                                                            
  |========================================                              |  57%
  |                                                                            
  |=============================================                         |  64%
  |                                                                            
  |==================================================                    |  71%
  |                                                                            
  |======================================================                |  78%
  |                                                                            
  |===========================================================           |  85%
  |                                                                            
  |================================================================      |  91%
  |                                                                            
  |===================================================================== |  98%
  |                                                                            
  |======================================================================| 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       auc   logloss
## 1    DeepLearning_grid_1_AutoML_13_20240430_110218_model_1 0.8648867 0.3968918
## 2             GBM_grid_1_AutoML_13_20240430_110218_model_1 0.8589536 0.3269150
## 3 StackedEnsemble_BestOfFamily_1_AutoML_13_20240430_110218 0.8558252 0.3076128
## 4                          GBM_1_AutoML_13_20240430_110218 0.8552319 0.3243584
## 5 StackedEnsemble_BestOfFamily_4_AutoML_13_20240430_110218 0.8543689 0.3244397
## 6         XGBoost_grid_1_AutoML_13_20240430_110218_model_3 0.8510787 0.3242023
##       aucpr mean_per_class_error      rmse        mse
## 1 0.6917862            0.2043689 0.3177864 0.10098819
## 2 0.6193157            0.2031553 0.3141580 0.09869523
## 3 0.6460828            0.2050162 0.3011894 0.09071507
## 4 0.6161812            0.2221683 0.3118296 0.09723772
## 5 0.6578135            0.1987864 0.2995784 0.08974721
## 6 0.5691088            0.2086570 0.3135505 0.09831391
## 
## [50 rows x 7 columns]
best_model <- models_h2o@leader
best_model
## Model Details:
## ==============
## 
## H2OBinomialModel: deeplearning
## Model ID:  DeepLearning_grid_1_AutoML_13_20240430_110218_model_1 
## Status of Neuron Layers: predicting Attrition, 2-class classification, bernoulli distribution, CrossEntropy loss, 6,202 weights/biases, 83.3 KB, 8,202 training samples, mini-batch size 1
##   layer units             type dropout       l1       l2 mean_rate rate_rms
## 1     1    59            Input  5.00 %       NA       NA        NA       NA
## 2     2   100 RectifierDropout 20.00 % 0.000000 0.000000  0.118182 0.316937
## 3     3     2          Softmax      NA 0.000000 0.000000  0.000417 0.000069
##   momentum mean_weight weight_rms mean_bias bias_rms
## 1       NA          NA         NA        NA       NA
## 2 0.000000    0.000248   0.110865  0.488417 0.023293
## 3 0.000000   -0.043919   0.559701 -0.000824 0.012990
## 
## 
## H2OBinomialMetrics: deeplearning
## ** Reported on training data. **
## ** Metrics reported on full training frame **
## 
## MSE:  0.09634606
## RMSE:  0.3103966
## LogLoss:  0.3816405
## Mean Per-Class Error:  0.2015651
## AUC:  0.8712267
## AUCPR:  0.6984956
## Gini:  0.7424535
## 
## Confusion Matrix (vertical: actual; across: predicted) for F1-optimal threshold:
##         No Yes    Error      Rate
## No     733  55 0.069797   =55/788
## Yes     50 100 0.333333   =50/150
## Totals 783 155 0.111940  =105/938
## 
## Maximum Metrics: Maximum metrics at their respective thresholds
##                         metric threshold      value idx
## 1                       max f1  0.089085   0.655738 148
## 2                       max f2  0.059804   0.683544 178
## 3                 max f0point5  0.164437   0.716724 104
## 4                 max accuracy  0.164437   0.902985 104
## 5                max precision  0.989795   1.000000   0
## 6                   max recall  0.000013   1.000000 399
## 7              max specificity  0.989795   1.000000   0
## 8             max absolute_mcc  0.148798   0.606998 108
## 9   max min_per_class_accuracy  0.022760   0.780457 252
## 10 max mean_per_class_accuracy  0.063665   0.808443 172
## 11                     max tns  0.989795 788.000000   0
## 12                     max fns  0.989795 149.000000   0
## 13                     max fps  0.000013 788.000000 399
## 14                     max tps  0.000013 150.000000 399
## 15                     max tnr  0.989795   1.000000   0
## 16                     max fnr  0.989795   0.993333   0
## 17                     max fpr  0.000013   1.000000 399
## 18                     max tpr  0.000013   1.000000 399
## 
## Gains/Lift Table: Extract with `h2o.gainsLift(<model>, <data>)` or `h2o.gainsLift(<model>, valid=<T/F>, xval=<T/F>)`
## H2OBinomialMetrics: deeplearning
## ** Reported on validation data. **
## ** Metrics reported on full validation frame **
## 
## MSE:  0.1155056
## RMSE:  0.3398611
## LogLoss:  0.4427683
## Mean Per-Class Error:  0.2553105
## AUC:  0.8270697
## AUCPR:  0.5655039
## Gini:  0.6541394
## 
## Confusion Matrix (vertical: actual; across: predicted) for F1-optimal threshold:
##         No Yes    Error     Rate
## No     127   9 0.066176   =9/136
## Yes     12  15 0.444444   =12/27
## Totals 139  24 0.128834  =21/163
## 
## Maximum Metrics: Maximum metrics at their respective thresholds
##                         metric threshold      value idx
## 1                       max f1  0.142432   0.588235  23
## 2                       max f2  0.005541   0.634518  88
## 3                 max f0point5  0.142432   0.609756  23
## 4                 max accuracy  0.344682   0.871166   9
## 5                max precision  0.987339   1.000000   0
## 6                   max recall  0.001059   1.000000 126
## 7              max specificity  0.987339   1.000000   0
## 8             max absolute_mcc  0.142432   0.513433  23
## 9   max min_per_class_accuracy  0.030671   0.705882  59
## 10 max mean_per_class_accuracy  0.058284   0.745098  41
## 11                     max tns  0.987339 136.000000   0
## 12                     max fns  0.987339  26.000000   0
## 13                     max fps  0.000004 136.000000 162
## 14                     max tps  0.001059  27.000000 126
## 15                     max tnr  0.987339   1.000000   0
## 16                     max fnr  0.987339   0.962963   0
## 17                     max fpr  0.000004   1.000000 162
## 18                     max tpr  0.001059   1.000000 126
## 
## Gains/Lift Table: Extract with `h2o.gainsLift(<model>, <data>)` or `h2o.gainsLift(<model>, valid=<T/F>, xval=<T/F>)`
## H2OBinomialMetrics: deeplearning
## ** Reported on cross-validation data. **
## ** 5-fold cross-validation on training data (Metrics computed for combined holdout predictions) **
## 
## MSE:  0.153224
## RMSE:  0.3914383
## LogLoss:  1.137627
## Mean Per-Class Error:  0.2999746
## AUC:  0.787923
## AUCPR:  0.504182
## Gini:  0.575846
## 
## Confusion Matrix (vertical: actual; across: predicted) for F1-optimal threshold:
##         No Yes    Error      Rate
## No     725  63 0.079949   =63/788
## Yes     78  72 0.520000   =78/150
## Totals 803 135 0.150320  =141/938
## 
## Maximum Metrics: Maximum metrics at their respective thresholds
##                         metric threshold      value idx
## 1                       max f1  0.001260   0.505263 132
## 2                       max f2  0.000124   0.604167 295
## 3                 max f0point5  0.003373   0.547809  87
## 4                 max accuracy  0.005941   0.864606  70
## 5                max precision  0.868487   1.000000   0
## 6                   max recall  0.000000   1.000000 399
## 7              max specificity  0.868487   1.000000   0
## 8             max absolute_mcc  0.001604   0.419685 125
## 9   max min_per_class_accuracy  0.000154   0.720812 280
## 10 max mean_per_class_accuracy  0.000146   0.733266 285
## 11                     max tns  0.868487 788.000000   0
## 12                     max fns  0.868487 149.000000   0
## 13                     max fps  0.000000 788.000000 399
## 14                     max tps  0.000000 150.000000 399
## 15                     max tnr  0.868487   1.000000   0
## 16                     max fnr  0.868487   0.993333   0
## 17                     max fpr  0.000000   1.000000 399
## 18                     max tpr  0.000000   1.000000 399
## 
## 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                 0.829326  0.085438   0.904255   0.808511   0.867021
## auc                      0.761476  0.059887   0.802954   0.725527   0.745992
## err                      0.170674  0.085438   0.095745   0.191489   0.132979
## err_count               32.000000 15.953056  18.000000  36.000000  25.000000
## f0point5                 0.544804  0.162463   0.755814   0.447368   0.573770
## f1                       0.521916  0.078442   0.590909   0.485714   0.528302
## f2                       0.523196  0.037940   0.485075   0.531250   0.489510
## lift_top_group           5.630000  1.405070   6.266667   6.266667   6.266667
## logloss                  1.242739  0.256118   0.802022   1.430429   1.258825
## max_per_class_error      0.460000  0.092496   0.566667   0.433333   0.533333
## mcc                      0.446174  0.125207   0.595638   0.376800   0.457883
## mean_per_class_accuracy  0.712171  0.025538   0.713502   0.710549   0.704852
## mean_per_class_error     0.287829  0.025538   0.286498   0.289451   0.295148
## mse                      0.155740  0.008159   0.141193   0.158987   0.158484
## pr_auc                   0.512051  0.129236   0.649604   0.415577   0.545015
## precision                0.577203  0.240054   0.928571   0.425000   0.608696
## r2                      -0.159224  0.059542  -0.052813  -0.185491  -0.181741
## recall                   0.540000  0.092496   0.433333   0.566667   0.466667
## rmse                     0.394527  0.010526   0.375757   0.398731   0.398100
## specificity              0.884343  0.117390   0.993671   0.854430   0.943038
##                         cv_4_valid cv_5_valid
## accuracy                  0.689840   0.877005
## auc                       0.692144   0.840764
## err                       0.310160   0.122995
## err_count                58.000000  23.000000
## f0point5                  0.331126   0.615942
## f1                        0.408163   0.596491
## f2                        0.531915   0.578231
## lift_top_group            3.116667   6.233333
## logloss                   1.409152   1.313270
## max_per_class_error       0.333333   0.433333
## mcc                       0.275366   0.525185
## mean_per_class_accuracy   0.680467   0.751486
## mean_per_class_error      0.319533   0.248514
## mse                       0.159976   0.160060
## pr_auc                    0.343212   0.606849
## precision                 0.294118   0.629630
## r2                       -0.187726  -0.188351
## recall                    0.666667   0.566667
## rmse                      0.399970   0.400075
## specificity               0.694268   0.936306

Save and Load

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

# h2o.getModel("DeepLearning_grid_1_AutoML_5_20240430_101059_model_1") %>%
#     h2o.saveModel("h2o_models/")
# 
# best_model <- h2o.loadModel("h2o_models/DeepLearning_grid_1_AutoML_5_20240430_101059_model_1")

Make predictions

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

predictions_tbl %>%
    bind_cols(test_tbl)
## # A tibble: 369 × 35
##    predict    No       Yes   Age Attrition BusinessTravel   DailyRate Department
##    <fct>   <dbl>     <dbl> <dbl> <fct>     <fct>                <dbl> <fct>     
##  1 No      0.999 0.000581     59 No        Travel_Rarely         1324 Research …
##  2 No      0.993 0.00674      35 No        Travel_Rarely          809 Research …
##  3 No      0.995 0.00515      34 No        Travel_Rarely         1346 Research …
##  4 No      0.986 0.0139       22 No        Non-Travel            1123 Research …
##  5 No      1.00  0.0000325    53 No        Travel_Rarely         1219 Sales     
##  6 No      0.990 0.0103       24 No        Non-Travel             673 Research …
##  7 No      0.979 0.0213       21 No        Travel_Rarely          391 Research …
##  8 No      0.968 0.0317       34 Yes       Travel_Rarely          699 Research …
##  9 No      1.00  0.000109     53 No        Travel_Rarely         1282 Research …
## 10 Yes     0.190 0.810        32 Yes       Travel_Frequent…      1125 Research …
## # ℹ 359 more rows
## # ℹ 27 more variables: DistanceFromHome <dbl>, Education <dbl>,
## #   EducationField <fct>, EmployeeNumber <dbl>, EnvironmentSatisfaction <dbl>,
## #   Gender <fct>, HourlyRate <dbl>, JobInvolvement <dbl>, JobLevel <dbl>,
## #   JobRole <fct>, JobSatisfaction <dbl>, MaritalStatus <fct>,
## #   MonthlyIncome <dbl>, MonthlyRate <dbl>, NumCompaniesWorked <dbl>,
## #   OverTime <fct>, PercentSalaryHike <dbl>, PerformanceRating <dbl>, …

Evaluate model

?h2o.performance
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] "DeepLearning_grid_1_AutoML_13_20240430_110218_model_1"
## 
## $model$type
## [1] "Key<Model>"
## 
## $model$URL
## [1] "/3/Models/DeepLearning_grid_1_AutoML_13_20240430_110218_model_1"
## 
## 
## $model_checksum
## [1] "-7290620826851224128"
## 
## $frame
## $frame$name
## [1] "test_tbl_sid_9b97_3"
## 
## 
## $frame_checksum
## [1] "-54413681510283746"
## 
## $description
## NULL
## 
## $scoring_time
## [1] 1.714489e+12
## 
## $predictions
## NULL
## 
## $MSE
## [1] 0.1009882
## 
## $RMSE
## [1] 0.3177864
## 
## $nobs
## [1] 369
## 
## $custom_metric_name
## NULL
## 
## $custom_metric_value
## [1] 0
## 
## $r2
## [1] 0.2583251
## 
## $logloss
## [1] 0.3968918
## 
## $AUC
## [1] 0.8648867
## 
## $pr_auc
## [1] 0.6917862
## 
## $Gini
## [1] 0.7297735
## 
## $mean_per_class_error
## [1] 0.2043689
## 
## $domain
## [1] "No"  "Yes"
## 
## $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
##         No Yes  Error       Rate
## No     296  13 0.0421 = 13 / 309
## Yes     22  38 0.3667 =  22 / 60
## Totals 318  51 0.0949 = 35 / 369
## 
## 
## $thresholds_and_metric_scores
## Metrics for Thresholds: Binomial metrics as a function of classification thresholds
##   threshold       f1       f2 f0point5 accuracy precision   recall specificity
## 1  0.976659 0.032787 0.020747 0.078125 0.840108  1.000000 0.016667    1.000000
## 2  0.929877 0.064516 0.041322 0.147059 0.842818  1.000000 0.033333    1.000000
## 3  0.875176 0.095238 0.061728 0.208333 0.845528  1.000000 0.050000    1.000000
## 4  0.845200 0.125000 0.081967 0.263158 0.848238  1.000000 0.066667    1.000000
## 5  0.844310 0.153846 0.102041 0.312500 0.850949  1.000000 0.083333    1.000000
##   absolute_mcc min_per_class_accuracy mean_per_class_accuracy tns fns fps tps
## 1     0.118299               0.016667                0.508333 309  59   0   1
## 2     0.167527               0.033333                0.516667 309  58   0   2
## 3     0.205458               0.050000                0.525000 309  57   0   3
## 4     0.237568               0.066667                0.533333 309  56   0   4
## 5     0.265973               0.083333                0.541667 309  55   0   5
##        tnr      fnr      fpr      tpr idx
## 1 1.000000 0.983333 0.000000 0.016667   0
## 2 1.000000 0.966667 0.000000 0.033333   1
## 3 1.000000 0.950000 0.000000 0.050000   2
## 4 1.000000 0.933333 0.000000 0.066667   3
## 5 1.000000 0.916667 0.000000 0.083333   4
## 
## ---
##     threshold       f1       f2 f0point5 accuracy precision   recall
## 364  0.000008 0.283019 0.496689 0.197889 0.176152  0.164835 1.000000
## 365  0.000005 0.282353 0.495868 0.197368 0.173442  0.164384 1.000000
## 366  0.000004 0.281690 0.495050 0.196850 0.170732  0.163934 1.000000
## 367  0.000003 0.281030 0.494234 0.196335 0.168022  0.163488 1.000000
## 368  0.000001 0.280374 0.493421 0.195822 0.165312  0.163043 1.000000
## 369  0.000000 0.279720 0.492611 0.195313 0.162602  0.162602 1.000000
##     specificity absolute_mcc min_per_class_accuracy mean_per_class_accuracy tns
## 364    0.016181     0.051645               0.016181                0.508091   5
## 365    0.012945     0.046130               0.012945                0.506472   4
## 366    0.009709     0.039895               0.009709                0.504854   3
## 367    0.006472     0.032530               0.006472                0.503236   2
## 368    0.003236     0.022971               0.003236                0.501618   1
## 369    0.000000     0.000000               0.000000                0.500000   0
##     fns fps tps      tnr      fnr      fpr      tpr idx
## 364   0 304  60 0.016181 0.000000 0.983819 1.000000 363
## 365   0 305  60 0.012945 0.000000 0.987055 1.000000 364
## 366   0 306  60 0.009709 0.000000 0.990291 1.000000 365
## 367   0 307  60 0.006472 0.000000 0.993528 1.000000 366
## 368   0 308  60 0.003236 0.000000 0.996764 1.000000 367
## 369   0 309  60 0.000000 0.000000 1.000000 1.000000 368
## 
## $max_criteria_and_metric_scores
## Maximum Metrics: Maximum metrics at their respective thresholds
##                         metric threshold      value idx
## 1                       max f1  0.113174   0.684685  50
## 2                       max f2  0.014028   0.670103 147
## 3                 max f0point5  0.178196   0.727273  39
## 4                 max accuracy  0.113174   0.905149  50
## 5                max precision  0.976659   1.000000   0
## 6                   max recall  0.000199   1.000000 332
## 7              max specificity  0.976659   1.000000   0
## 8             max absolute_mcc  0.113174   0.632173  50
## 9   max min_per_class_accuracy  0.025512   0.783333 111
## 10 max mean_per_class_accuracy  0.113174   0.795631  50
## 11                     max tns  0.976659 309.000000   0
## 12                     max fns  0.976659  59.000000   0
## 13                     max fps  0.000000 309.000000 368
## 14                     max tps  0.000199  60.000000 332
## 15                     max tnr  0.976659   1.000000   0
## 16                     max fnr  0.976659   0.983333   0
## 17                     max fpr  0.000000   1.000000 368
## 18                     max tpr  0.000199   1.000000 332
## 
## $gains_lift_table
## Gains/Lift Table: Avg response rate: 16.26 %, avg score:  6.73 %
##    group cumulative_data_fraction lower_threshold     lift cumulative_lift
## 1      1               0.01084011        0.844595 6.150000        6.150000
## 2      2               0.02168022        0.726109 6.150000        6.150000
## 3      3               0.03252033        0.578426 6.150000        6.150000
## 4      4               0.04065041        0.479439 2.050000        5.330000
## 5      5               0.05149051        0.381714 4.612500        5.178947
## 6      6               0.10027100        0.206685 4.441667        4.820270
## 7      7               0.15176152        0.103748 2.913158        4.173214
## 8      8               0.20054201        0.065526 0.683333        3.324324
## 9      9               0.30081301        0.026618 0.997297        2.548649
## 10    10               0.40108401        0.014017 0.997297        2.160811
## 11    11               0.50135501        0.007349 0.332432        1.795135
## 12    12               0.59891599        0.004044 0.341667        1.558371
## 13    13               0.69918699        0.002067 0.166216        1.358721
## 14    14               0.79945799        0.000646 0.166216        1.209153
## 15    15               0.89972900        0.000212 0.166216        1.092922
## 16    16               1.00000000        0.000000 0.166216        1.000000
##    response_rate    score cumulative_response_rate cumulative_score
## 1       1.000000 0.906728                 1.000000         0.906728
## 2       1.000000 0.803167                 1.000000         0.854948
## 3       1.000000 0.618807                 1.000000         0.776234
## 4       0.333333 0.519289                 0.866667         0.724845
## 5       0.750000 0.428765                 0.842105         0.662512
## 6       0.722222 0.283616                 0.783784         0.478184
## 7       0.473684 0.139358                 0.678571         0.363226
## 8       0.111111 0.082208                 0.540541         0.294870
## 9       0.162162 0.042455                 0.414414         0.210732
## 10      0.162162 0.018852                 0.351351         0.162762
## 11      0.054054 0.010349                 0.291892         0.132279
## 12      0.055556 0.005652                 0.253394         0.111652
## 13      0.027027 0.002863                 0.220930         0.096050
## 14      0.027027 0.001240                 0.196610         0.084159
## 15      0.027027 0.000403                 0.177711         0.074825
## 16      0.027027 0.000075                 0.162602         0.067329
##    capture_rate cumulative_capture_rate       gain cumulative_gain
## 1      0.066667                0.066667 515.000000      515.000000
## 2      0.066667                0.133333 515.000000      515.000000
## 3      0.066667                0.200000 515.000000      515.000000
## 4      0.016667                0.216667 105.000000      433.000000
## 5      0.050000                0.266667 361.250000      417.894737
## 6      0.216667                0.483333 344.166667      382.027027
## 7      0.150000                0.633333 191.315789      317.321429
## 8      0.033333                0.666667 -31.666667      232.432432
## 9      0.100000                0.766667  -0.270270      154.864865
## 10     0.100000                0.866667  -0.270270      116.081081
## 11     0.033333                0.900000 -66.756757       79.513514
## 12     0.033333                0.933333 -65.833333       55.837104
## 13     0.016667                0.950000 -83.378378       35.872093
## 14     0.016667                0.966667 -83.378378       20.915254
## 15     0.016667                0.983333 -83.378378        9.292169
## 16     0.016667                1.000000 -83.378378        0.000000
##    kolmogorov_smirnov
## 1            0.066667
## 2            0.133333
## 3            0.200000
## 4            0.210194
## 5            0.256958
## 6            0.457443
## 7            0.575081
## 8            0.556634
## 9            0.556311
## 10           0.555987
## 11           0.476052
## 12           0.399353
## 13           0.299515
## 14           0.199676
## 15           0.099838
## 16           0.000000
h2o.auc(performance_h2o)
## [1] 0.8648867
h2o.confusionMatrix(performance_h2o)
## Confusion Matrix (vertical: actual; across: predicted)  for max f1 @ threshold = 0.113174371154645:
##         No Yes    Error     Rate
## No     296  13 0.042071  =13/309
## Yes     22  38 0.366667   =22/60
## Totals 318  51 0.094851  =35/369