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: 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

h2o.init()
##  Connection successful!
## 
## R is connected to the H2O cluster: 
##     H2O cluster uptime:         1 hours 49 minutes 
##     H2O cluster timezone:       America/New_York 
##     H2O data parsing timezone:  UTC 
##     H2O cluster version:        3.44.0.3 
##     H2O cluster version age:    10 months and 30 days 
##     H2O cluster name:           H2O_started_from_R_eliza_fhp551 
##     H2O cluster total nodes:    1 
##     H2O cluster total memory:   3.53 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 (10 months and 30 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, 
    max_models        = 10, 
    exclude_algos     = "DeepLearning",
    nfolds            = 5, 
    seed              = 3456   
)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |=========                                                             |  12%
## 23:32:17.715: 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.
## 23:32:17.720: AutoML: XGBoost is not available; skipping it.
  |                                                                            
  |============================================                          |  62%
  |                                                                            
  |======================================================================| 100%
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             GBM_grid_1_AutoML_5_20241119_233217_model_1 0.8589536 0.3269150
## 2 StackedEnsemble_BestOfFamily_1_AutoML_5_20241119_233217 0.8489213 0.3120121
## 3                          GBM_1_AutoML_5_20241119_233217 0.8485976 0.3241789
## 4    StackedEnsemble_AllModels_1_AutoML_5_20241119_233217 0.8459547 0.3086959
## 5                          GLM_1_AutoML_5_20241119_233217 0.8400216 0.3186222
## 6                          GBM_4_AutoML_5_20241119_233217 0.8123517 0.3439750
##       aucpr mean_per_class_error      rmse        mse
## 1 0.6193157            0.2031553 0.3141580 0.09869523
## 2 0.6388749            0.2508900 0.3021263 0.09128029
## 3 0.6066085            0.2404531 0.3118557 0.09725395
## 4 0.6272661            0.2393204 0.3000865 0.09005189
## 5 0.6515822            0.2369741 0.3064601 0.09391777
## 6 0.5489556            0.2654531 0.3191061 0.10182871
## 
## [12 rows x 7 columns]

Save and Load

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

best_model <- h2o.loadModel("h2o_models/StackedEnsemble_BestOfFamily_4_AutoML_3_20241119_223041")

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.752 0.248      59 No        Travel_Rarely          1324 Research &…
##  2 No      0.907 0.0931     35 No        Travel_Rarely           809 Research &…
##  3 No      0.869 0.131      34 No        Travel_Rarely          1346 Research &…
##  4 Yes     0.589 0.411      22 No        Non-Travel             1123 Research &…
##  5 No      0.985 0.0149     53 No        Travel_Rarely          1219 Sales      
##  6 No      0.973 0.0271     24 No        Non-Travel              673 Research &…
##  7 No      0.813 0.187      21 No        Travel_Rarely           391 Research &…
##  8 No      0.865 0.135      34 Yes       Travel_Rarely           699 Research &…
##  9 No      0.998 0.00189    53 No        Travel_Rarely          1282 Research &…
## 10 Yes     0.236 0.764      32 Yes       Travel_Frequently      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

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_4_AutoML_3_20241119_223041"
## 
## $model$type
## [1] "Key<Model>"
## 
## $model$URL
## [1] "/3/Models/StackedEnsemble_BestOfFamily_4_AutoML_3_20241119_223041"
## 
## 
## $model_checksum
## [1] "4645873825974922480"
## 
## $frame
## $frame$name
## [1] "test_tbl_sid_b501_3"
## 
## 
## $frame_checksum
## [1] "-54413681510283746"
## 
## $description
## NULL
## 
## $scoring_time
## [1] 1.732077e+12
## 
## $predictions
## NULL
## 
## $MSE
## [1] 0.0950839
## 
## $RMSE
## [1] 0.3083568
## 
## $nobs
## [1] 369
## 
## $custom_metric_name
## NULL
## 
## $custom_metric_value
## [1] 0
## 
## $r2
## [1] 0.3016872
## 
## $logloss
## [1] 0.3230807
## 
## $AUC
## [1] 0.8370011
## 
## $pr_auc
## [1] 0.6218335
## 
## $Gini
## [1] 0.6740022
## 
## $mean_per_class_error
## [1] 0.2251618
## 
## $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     278  31 0.1003 = 31 / 309
## Yes     21  39 0.3500 =  21 / 60
## Totals 299  70 0.1409 = 52 / 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.944826 0.032787 0.020747 0.078125 0.840108  1.000000 0.016667    1.000000
## 2  0.915797 0.064516 0.041322 0.147059 0.842818  1.000000 0.033333    1.000000
## 3  0.884152 0.095238 0.061728 0.208333 0.845528  1.000000 0.050000    1.000000
## 4  0.833643 0.125000 0.081967 0.263158 0.848238  1.000000 0.066667    1.000000
## 5  0.831328 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.002934 0.283019 0.496689 0.197889 0.176152  0.164835 1.000000
## 365  0.002767 0.282353 0.495868 0.197368 0.173442  0.164384 1.000000
## 366  0.002288 0.281690 0.495050 0.196850 0.170732  0.163934 1.000000
## 367  0.001886 0.281030 0.494234 0.196335 0.168022  0.163488 1.000000
## 368  0.001804 0.280374 0.493421 0.195822 0.165312  0.163043 1.000000
## 369  0.001307 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.327281   0.600000  69
## 2                       max f2  0.209127   0.646067 115
## 3                 max f0point5  0.532289   0.679348  30
## 4                 max accuracy  0.532289   0.888889  30
## 5                max precision  0.944826   1.000000   0
## 6                   max recall  0.012361   1.000000 333
## 7              max specificity  0.944826   1.000000   0
## 8             max absolute_mcc  0.532289   0.528419  30
## 9   max min_per_class_accuracy  0.209127   0.766667 115
## 10 max mean_per_class_accuracy  0.327281   0.774838  69
## 11                     max tns  0.944826 309.000000   0
## 12                     max fns  0.944826  59.000000   0
## 13                     max fps  0.001307 309.000000 368
## 14                     max tps  0.012361  60.000000 333
## 15                     max tnr  0.944826   1.000000   0
## 16                     max fnr  0.944826   0.983333   0
## 17                     max fpr  0.001307   1.000000 368
## 18                     max tpr  0.012361   1.000000 333
## 
## $gains_lift_table
## Gains/Lift Table: Avg response rate: 16.26 %, avg score: 18.45 %
##    group cumulative_data_fraction lower_threshold     lift cumulative_lift
## 1      1               0.01084011        0.832069 6.150000        6.150000
## 2      2               0.02168022        0.764136 4.612500        5.381250
## 3      3               0.03252033        0.741767 6.150000        5.637500
## 4      4               0.04065041        0.694872 6.150000        5.740000
## 5      5               0.05149051        0.667062 1.537500        4.855263
## 6      6               0.10027100        0.508513 3.758333        4.321622
## 7      7               0.15176152        0.402314 1.942105        3.514286
## 8      8               0.20054201        0.305155 2.391667        3.241216
## 9      9               0.30081301        0.220540 0.997297        2.493243
## 10    10               0.40108401        0.144400 0.664865        2.036149
## 11    11               0.50135501        0.101989 0.166216        1.662162
## 12    12               0.59891599        0.070369 0.512500        1.474887
## 13    13               0.69918699        0.042530 0.498649        1.334884
## 14    14               0.79945799        0.027457 0.332432        1.209153
## 15    15               0.89972900        0.013169 0.166216        1.092922
## 16    16               1.00000000        0.001307 0.166216        1.000000
##    response_rate    score cumulative_response_rate cumulative_score
## 1       1.000000 0.894605                 1.000000         0.894605
## 2       0.750000 0.788268                 0.875000         0.841436
## 3       1.000000 0.752144                 0.916667         0.811672
## 4       1.000000 0.710666                 0.933333         0.791471
## 5       0.250000 0.684720                 0.789474         0.768997
## 6       0.611111 0.566749                 0.702703         0.670606
## 7       0.315789 0.461224                 0.571429         0.599566
## 8       0.388889 0.353137                 0.527027         0.539624
## 9       0.162162 0.256543                 0.405405         0.445264
## 10      0.108108 0.180668                 0.331081         0.379115
## 11      0.027027 0.122835                 0.270270         0.327859
## 12      0.083333 0.084634                 0.239819         0.288238
## 13      0.081081 0.054841                 0.217054         0.254767
## 14      0.054054 0.035727                 0.196610         0.227294
## 15      0.027027 0.020368                 0.177711         0.204233
## 16      0.027027 0.007472                 0.162602         0.184504
##    capture_rate cumulative_capture_rate       gain cumulative_gain
## 1      0.066667                0.066667 515.000000      515.000000
## 2      0.050000                0.116667 361.250000      438.125000
## 3      0.066667                0.183333 515.000000      463.750000
## 4      0.050000                0.233333 515.000000      474.000000
## 5      0.016667                0.250000  53.750000      385.526316
## 6      0.183333                0.433333 275.833333      332.162162
## 7      0.100000                0.533333  94.210526      251.428571
## 8      0.116667                0.650000 139.166667      224.121622
## 9      0.100000                0.750000  -0.270270      149.324324
## 10     0.066667                0.816667 -33.513514      103.614865
## 11     0.016667                0.833333 -83.378378       66.216216
## 12     0.050000                0.883333 -48.750000       47.488688
## 13     0.050000                0.933333 -50.135135       33.488372
## 14     0.033333                0.966667 -66.756757       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.113430
## 3            0.180097
## 4            0.230097
## 5            0.237055
## 6            0.397735
## 7            0.455663
## 8            0.536731
## 9            0.536408
## 10           0.496278
## 11           0.396440
## 12           0.339644
## 13           0.279612
## 14           0.199676
## 15           0.099838
## 16           0.000000
## 
## $residual_deviance
## [1] 238.4335
## 
## $null_deviance
## [1] 327.9212
## 
## $AIC
## [1] 250.4335
## 
## $loglikelihood
## [1] 0
## 
## $null_degrees_of_freedom
## [1] 368
## 
## $residual_degrees_of_freedom
## [1] 363
h2o.auc(performance_h2o)
## [1] 0.8370011
h2o.confusionMatrix(performance_h2o)
## Confusion Matrix (vertical: actual; across: predicted)  for max f1 @ threshold = 0.327281159662961:
##         No Yes    Error     Rate
## No     278  31 0.100324  =31/309
## Yes     21  39 0.350000   =21/60
## Totals 299  70 0.140921  =52/369
h2o.metric(performance_h2o)
## Metrics for Thresholds: Binomial metrics as a function of classification thresholds
##   threshold       f1       f2 f0point5 accuracy precision   recall specificity
## 1  0.944826 0.032787 0.020747 0.078125 0.840108  1.000000 0.016667    1.000000
## 2  0.915797 0.064516 0.041322 0.147059 0.842818  1.000000 0.033333    1.000000
## 3  0.884152 0.095238 0.061728 0.208333 0.845528  1.000000 0.050000    1.000000
## 4  0.833643 0.125000 0.081967 0.263158 0.848238  1.000000 0.066667    1.000000
## 5  0.831328 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.002934 0.283019 0.496689 0.197889 0.176152  0.164835 1.000000
## 365  0.002767 0.282353 0.495868 0.197368 0.173442  0.164384 1.000000
## 366  0.002288 0.281690 0.495050 0.196850 0.170732  0.163934 1.000000
## 367  0.001886 0.281030 0.494234 0.196335 0.168022  0.163488 1.000000
## 368  0.001804 0.280374 0.493421 0.195822 0.165312  0.163043 1.000000
## 369  0.001307 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