library(tidyverse)

attrition_raw_tbl <- read_csv(“../00_data/WA_Fn-UseC_-HR-Employee-Attrition.csv”)

If data is not sensitive:

attrition_raw_tbl %>% glimpse()

If data is sensitive:

attrition_raw_tbl %>% slice(0) %>% glimpse()

library(tidyverse)
## Warning: package 'ggplot2' was built under R version 4.3.2
## ── Attaching core tidyverse packages ──────────────────────── tidyverse 2.0.0 ──
## ✔ dplyr     1.1.3     ✔ readr     2.1.4
## ✔ forcats   1.0.0     ✔ stringr   1.5.0
## ✔ ggplot2   3.5.0     ✔ tibble    3.2.1
## ✔ lubridate 1.9.2     ✔ tidyr     1.3.0
## ✔ purrr     1.0.2     
## ── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
## ✖ dplyr::filter() masks stats::filter()
## ✖ dplyr::lag()    masks stats::lag()
## ℹ Use the conflicted package (<http://conflicted.r-lib.org/>) to force all conflicts to become errors
attrition_raw_tbl <- read_csv("../00_data/WA_Fn-UseC_-HR-Employee-Attrition.csv")
## Rows: 1470 Columns: 35
## ── Column specification ────────────────────────────────────────────────────────
## Delimiter: ","
## chr  (9): Attrition, BusinessTravel, Department, EducationField, Gender, Job...
## dbl (26): Age, DailyRate, DistanceFromHome, Education, EmployeeCount, Employ...
## 
## ℹ 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.
# Load required libraries
library(tidyverse)
library(tidymodels)
## Warning: package 'tidymodels' was built under R version 4.3.2
## ── 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.3
## ✔ modeldata    1.3.0     ✔ workflowsets 1.0.1
## ✔ parsnip      1.1.1     ✔ yardstick    1.3.0
## ✔ recipes      1.0.8
## Warning: package 'dials' was built under R version 4.3.2
## Warning: package 'scales' was built under R version 4.3.2
## Warning: package 'infer' was built under R version 4.3.2
## Warning: package 'modeldata' was built under R version 4.3.2
## Warning: package 'parsnip' was built under R version 4.3.2
## Warning: package 'tune' was built under R version 4.3.2
## Warning: package 'workflows' was built under R version 4.3.2
## Warning: package 'workflowsets' was built under R version 4.3.2
## Warning: package 'yardstick' was built under R version 4.3.2
## ── 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 tidymodels_prefer() to resolve common conflicts.
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:lubridate':
## 
##     day, hour, month, week, year
## 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
# Step 1: Split the data into training and testing sets
set.seed(42) # for reproducibility
split <- initial_split(attrition_raw_tbl, prop = 0.7, strata = Attrition)
train_data <- training(split)
test_data <- testing(split)

# Step 2: Preprocess the data using tidymodels
attrition_recipe <- recipe(Attrition ~ ., data = train_data) %>%
  step_rm(Over18) %>%  # Remove the Over18 column
  step_dummy(all_nominal(), -all_outcomes())

# Fit and preprocess the recipe
attrition_recipe <- attrition_recipe %>%
  prep(training = train_data, retain = TRUE)

train_data <- bake(attrition_recipe, new_data = train_data)
test_data <- bake(attrition_recipe, new_data = test_data)

# Step 3: Initialize and connect to the H2O cluster
h2o.init()
##  Connection successful!
## 
## R is connected to the H2O cluster: 
##     H2O cluster uptime:         1 hours 21 minutes 
##     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 16 days 
##     H2O cluster name:           H2O_started_from_R_Jstan_fhp551 
##     H2O cluster total nodes:    1 
##     H2O cluster total memory:   1.73 GB 
##     H2O cluster total cores:    8 
##     H2O cluster allowed cores:  8 
##     H2O cluster healthy:        TRUE 
##     H2O Connection ip:          localhost 
##     H2O Connection port:        54321 
##     H2O Connection proxy:       NA 
##     H2O Internal Security:      FALSE 
##     R Version:                  R version 4.3.1 (2023-06-16 ucrt)
## Warning in h2o.clusterInfo(): 
## Your H2O cluster version is (4 months and 16 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
# Step 4: Convert data to H2O frame
train_h2o <- as.h2o(train_data)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
test_h2o <- as.h2o(test_data)
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |======================================================================| 100%
# Step 5: Build a predictive model using H2O
attrition_gbm <- h2o.gbm(x = names(train_data)[-which(names(train_data) == "Attrition")],
                         y = "Attrition",
                         training_frame = train_h2o,
                         validation_frame = test_h2o,
                         ntrees = 50,
                         learn_rate = 0.1,
                         max_depth = 5)
## Warning in .h2o.processResponseWarnings(res): Dropping bad and constant columns: [StandardHours, EmployeeCount].
## 
  |                                                                            
  |                                                                      |   0%
  |                                                                            
  |============================                                          |  40%
  |                                                                            
  |======================================================================| 100%
# Step 6: Evaluate the model
h2o_performance <- h2o.performance(attrition_gbm, newdata = test_h2o)
accuracy <- h2o.metric(h2o_performance, metric = "accuracy")
print(paste("Accuracy:", accuracy))
## [1] "Accuracy: c(0.881435890955366, 0.861833366971904, 0.859046346272287, 0.813109918979478, 0.804631718604866, 0.797886478192222, 0.797052603415294, 0.762975957203997, 0.759683549778711, 0.745635300497742, 0.714551699363993, 0.691234370093383, 0.680621972442985, 0.670999316732122, 0.648531279931761, 0.639807765802242, 0.621431845447391, 0.616741504420667, 0.584524928713962, 0.575800899929655, 0.565128189670932, 0.557378276186919, 0.534467151809433, 0.533866405584117, 0.499368676803341, 0.49860567643512, 0.481870753262045, \n0.473762148412849, 0.471003383928806, 0.465528711874401, 0.460826111063887, 0.454793147879075, 0.444804611508906, 0.41935976861901, 0.418754252053475, 0.411447231434128, 0.408279770834376, 0.398275071882186, 0.397105743905793, 0.392725223806602, 0.39006040933607, 0.387270509031791, 0.382903822414662, 0.374939791383332, 0.374687938348496, 0.374245858724768, 0.362263398221681, 0.361985032044708, 0.339466610005052, 0.336025151147237, 0.331421051819523, 0.330981164525221, 0.328919060702542, 0.326374444779855, \n0.31247355642056, 0.309094623104448, 0.308700128587155, 0.302574425993707, 0.299149781699074, 0.29343415801473, 0.290303246343537, 0.279502817084334, 0.275896859764658, 0.271589008157089, 0.269661706414933, 0.244394351829742, 0.242900967666474, 0.242085439212417, 0.241730223622176, 0.238110273104754, 0.232778217150926, 0.221824150632779, 0.215337308751549, 0.210962385906207, 0.206890885502725, 0.201545924867604, 0.195022971880539, 0.19067354939578, 0.188595558667258, 0.187472483782723, 0.185133728256229, \n0.184631651199404, 0.184543358865892, 0.184178343927353, 0.182812310882775, 0.182169704842157, 0.179853136217359, 0.179513386938729, 0.176236724891907, 0.176181552935945, 0.175610001706334, 0.174202766254847, 0.172022163378581, 0.170179263063768, 0.169945455726703, 0.169609829226389, 0.169346323381021, 0.169141234742433, 0.167717010480989, 0.165248817019008, 0.164919740523808, 0.161730478486569, 0.161337323395625, 0.161166997455659, 0.159479735630505, 0.158170494566733, 0.1553788198892, 0.15504447624015, \n0.153503694563999, 0.153415656510589, 0.152004863875853, 0.151703674130927, 0.151161005439167, 0.145884124592143, 0.138704453351679, 0.137663859064376, 0.136327206783115, 0.134312172152887, 0.13349928560019, 0.131016549912683, 0.130317523748951, 0.129247270648765, 0.129154285326875, 0.127696514743075, 0.127418733130896, 0.126717342396271, 0.124989036907333, 0.124374675054231, 0.124204539758926, 0.121592093730731, 0.119512343530194, 0.117748011449451, 0.116288619341249, 0.115495689762722, 0.115437024848426, \n0.114148036845396, 0.11364767135562, 0.110451251309228, 0.107954511897158, 0.105932904638662, 0.104458045902731, 0.103354344318595, 0.102785721318547, 0.10166525133649, 0.10063312309484, 0.099944184385021, 0.0994508592271297, 0.0984957656453028, 0.0981536076384451, 0.09763422541504, 0.0974966184845787, 0.0948945941984665, 0.0944032535556262, 0.0938089966733197, 0.0917264584307667, 0.0914729597828671, 0.0901145483945038, 0.0898765279086809, 0.0889812315381792, 0.088357184564766, 0.0882508814919553, \n0.0876235124535207, 0.0874679659345047, 0.0870990054235397, 0.0859071129650904, 0.0852716664119173, 0.0851250416433636, 0.084864272599803, 0.0834217761407338, 0.0833174209535447, 0.0820200760790013, 0.0808306826927386, 0.0805712652102637, 0.0804973301225762, 0.079651490310933, 0.0774531190067951, 0.077222176199759, 0.0771367022094204, 0.0770230271010335, 0.0759466567132067, 0.0749156579064209, 0.0745308757391517, 0.074193206895673, 0.0717470987944807, 0.0714177966258817, 0.0712879427647453, 0.0708243782309749, \n0.070434659861049, 0.0698785113764069, 0.0696856009314367, 0.0692446716269519, 0.0691406778191015, 0.0687529222787924, 0.0683348676300993, 0.0682179431466971, 0.0680805708618849, 0.0680430746962649, 0.0675054123145025, 0.0674040482031956, 0.0651898634423299, 0.064671641734237, 0.0644403585712493, 0.0641498118709205, 0.0638654290714349, 0.0634738071417783, 0.0630585050421428, 0.0629116065296147, 0.0626308785136833, 0.0617867341529647, 0.0601194731858969, 0.0597593529347714, 0.0596298881490044, 0.0586819734945161, \n0.0586284378882235, 0.057708380005905, 0.0551981276404262, 0.0545428861043058, 0.0541696610830442, 0.0541291571297264, 0.0539802722432663, 0.0537624682757401, 0.0537073067458784, 0.0531547947120216, 0.0529901910082938, 0.0529179607437127, 0.0523242036836342, 0.0520058150127893, 0.0508450590666336, 0.0501992137791393, 0.0499682905509831, 0.0488338986441878, 0.0487174228256815, 0.0486273641807234, 0.0485171409733361, 0.0467534781837965, 0.0466959771246481, 0.0464074647589852, 0.0460149242459392, 0.0459602282530135, \n0.0451953710592657, 0.0450887091577605, 0.0449523573075229, 0.04422434377867, 0.0436448141785131, 0.0435929567498503, 0.043496170307655, 0.0434235206273907, 0.0430956344403194, 0.042821366345409, 0.0423759272938133, 0.0414049245522356, 0.0408669333364157, 0.0404492669372803, 0.0402294989443576, 0.0401752219489836, 0.0401174661426945, 0.039928682905367, 0.0396753152321017, 0.0389297130922356, 0.038594018092133, 0.0385461750164706, 0.0384231334425879, 0.0381052018524377, 0.0380618447796679, 0.0378720062426424, \n0.0376801649510554, 0.0374281451645917, 0.0372243259165045, 0.0369269188371401, 0.0367525843355445, 0.0366515201086151, 0.0365299602844039, 0.0364914492038693, 0.0363949643408762, 0.0363589204958623, 0.0346452627943055, 0.034563804331614, 0.0340854726728682, 0.0340318355460635, 0.0337869109407556, 0.0335077961267188, 0.03341373987735, 0.0330896728607366, 0.0323430843113102, 0.0322118329819499, 0.0321594467364503, 0.03201985534163, 0.0317925527582042, 0.0315947931163461, 0.0313442533969673, 0.031011831091112, \n0.0309405616846108, 0.0308803044361063, 0.0305815104926429, 0.0301540278818609, 0.0300671276811467, 0.0298505530367128, 0.0296188326514416, 0.0291063532788131, 0.0290642753409733, 0.02897356145708, 0.028471745738283, 0.0277292152022669, 0.0271094508796843, 0.0268585276123542, 0.026824905024933, 0.0265121263886567, 0.026234421534538, 0.0261088094125059, 0.0258027059722778, 0.0257191331656739, 0.0255226914624736, 0.0254297273640904, 0.0253769241658339, 0.0252509949020222, 0.0251014580191182, 0.0250209827040046, \n0.0247201303797116, 0.0246248484429393, 0.0244212890974541, 0.0242040824605861, 0.0239271889530092, 0.0238281973312611, 0.0235612714910753, 0.0234937581869298, 0.0232321423774705, 0.0231906137292527, 0.0230617152460955, 0.022982198871009, 0.022766035434813, 0.0226825480330097, 0.0226273702175304, 0.0221380344621357, 0.0219569365831374, 0.0218650327180414, 0.021369210646074, 0.0213105745066279, 0.0212669378526563, 0.0210888326778608, 0.020577652736658, 0.0204495456423909, 0.0203243493580133, 0.0202043353068995, \n0.0200799216935697, 0.0199797409516973, 0.0194640501692324, 0.0192511959995329, 0.0191790002370866, 0.0190142448193076, 0.0188516371329852, 0.0188043090316449, 0.0186810585343127, 0.0186319053766328, 0.0184519932891804, 0.0182522818932876, 0.0179608373470342, 0.0179191775590456, 0.0178620914955763, 0.0175899566260695, 0.0175358505815727, 0.0173649629530812, 0.017212803753701, 0.0170862461878109, 0.0169363752889688, 0.0168976030308812, 0.0166460389982225, 0.0161760467667972, 0.016016763729096, 0.0159234635721215, \n0.0157697725331892, 0.0156433052128022, 0.0155255726860112, 0.0151990935970653, 0.0148403186083458, 0.0147549631735637, 0.0145863416947014, 0.0144068873568927, 0.014333016415781, 0.0142144295607192, 0.0140880216686851, 0.0138367654232097, 0.0136775481265799, 0.0133660819371855, 0.0132938722801674, 0.0131950917702525, 0.013070313902534, 0.013020755425597, 0.0128714995326577, 0.0127490720965475, 0.0125149698650209, 0.0120563956103283, 0.0117437102214895, 0.0117057995954761, 0.0111127193336858, 0.0107147392073478, \n0.0105382518459546, 0.0104681792345185, 0.00957478905094791, 0.00949407030258609, 0.00910904907715848)"
## [2] "Accuracy: c(0.839366515837104, 0.841628959276018, 0.843891402714932, 0.846153846153846, 0.84841628959276, 0.850678733031674, 0.852941176470588, 0.855203619909502, 0.857466063348416, 0.855203619909502, 0.852941176470588, 0.850678733031674, 0.852941176470588, 0.850678733031674, 0.852941176470588, 0.850678733031674, 0.852941176470588, 0.850678733031674, 0.852941176470588, 0.850678733031674, 0.84841628959276, 0.850678733031674, 0.852941176470588, 0.855203619909502, 0.852941176470588, 0.850678733031674, 0.852941176470588, \n0.855203619909502, 0.857466063348416, 0.855203619909502, 0.852941176470588, 0.855203619909502, 0.852941176470588, 0.855203619909502, 0.857466063348416, 0.855203619909502, 0.852941176470588, 0.850678733031674, 0.84841628959276, 0.850678733031674, 0.84841628959276, 0.850678733031674, 0.84841628959276, 0.850678733031674, 0.852941176470588, 0.850678733031674, 0.852941176470588, 0.850678733031674, 0.84841628959276, 0.846153846153846, 0.843891402714932, 0.841628959276018, 0.839366515837104, 0.841628959276018, \n0.839366515837104, 0.83710407239819, 0.839366515837104, 0.841628959276018, 0.839366515837104, 0.83710407239819, 0.839366515837104, 0.83710407239819, 0.834841628959276, 0.83710407239819, 0.834841628959276, 0.832579185520362, 0.830316742081448, 0.828054298642534, 0.823529411764706, 0.82579185520362, 0.828054298642534, 0.82579185520362, 0.823529411764706, 0.82579185520362, 0.823529411764706, 0.821266968325792, 0.823529411764706, 0.821266968325792, 0.819004524886878, 0.816742081447964, 0.81447963800905, \n0.816742081447964, 0.819004524886878, 0.816742081447964, 0.819004524886878, 0.816742081447964, 0.81447963800905, 0.816742081447964, 0.81447963800905, 0.816742081447964, 0.81447963800905, 0.816742081447964, 0.81447963800905, 0.812217194570136, 0.81447963800905, 0.816742081447964, 0.819004524886878, 0.816742081447964, 0.81447963800905, 0.812217194570136, 0.809954751131222, 0.807692307692308, 0.805429864253394, 0.80316742081448, 0.800904977375566, 0.796380090497738, 0.794117647058823, 0.791855203619909, \n0.789592760180995, 0.787330316742081, 0.785067873303167, 0.782805429864253, 0.780542986425339, 0.778280542986425, 0.776018099547511, 0.773755656108597, 0.776018099547511, 0.773755656108597, 0.771493212669683, 0.769230769230769, 0.771493212669683, 0.769230769230769, 0.766968325791855, 0.764705882352941, 0.762443438914027, 0.760180995475113, 0.757918552036199, 0.755656108597285, 0.753393665158371, 0.751131221719457, 0.748868778280543, 0.746606334841629, 0.748868778280543, 0.751131221719457, 0.748868778280543, \n0.746606334841629, 0.744343891402715, 0.742081447963801, 0.744343891402715, 0.742081447963801, 0.739819004524887, 0.737556561085973, 0.735294117647059, 0.737556561085973, 0.737556561085973, 0.735294117647059, 0.733031674208145, 0.730769230769231, 0.728506787330317, 0.726244343891403, 0.723981900452489, 0.721719457013575, 0.719457013574661, 0.717194570135747, 0.714932126696833, 0.712669683257919, 0.714932126696833, 0.712669683257919, 0.710407239819005, 0.708144796380091, 0.705882352941177, 0.703619909502262, \n0.701357466063348, 0.699095022624434, 0.69683257918552, 0.694570135746606, 0.692307692307692, 0.690045248868778, 0.687782805429864, 0.68552036199095, 0.683257918552036, 0.680995475113122, 0.678733031674208, 0.676470588235294, 0.67420814479638, 0.669683257918552, 0.667420814479638, 0.665158371040724, 0.660633484162896, 0.656108597285068, 0.658371040723982, 0.660633484162896, 0.658371040723982, 0.656108597285068, 0.649321266968326, 0.65158371040724, 0.649321266968326, 0.647058823529412, 0.644796380090498, \n0.642533936651584, 0.64027149321267, 0.638009049773756, 0.635746606334842, 0.633484162895928, 0.631221719457014, 0.6289592760181, 0.631221719457014, 0.6289592760181, 0.626696832579186, 0.624434389140271, 0.622171945701357, 0.619909502262443, 0.617647058823529, 0.615384615384615, 0.613122171945701, 0.615384615384615, 0.613122171945701, 0.610859728506787, 0.608597285067873, 0.604072398190045, 0.601809954751131, 0.599547511312217, 0.597285067873303, 0.595022624434389, 0.592760180995475, 0.590497737556561, \n0.585972850678733, 0.583710407239819, 0.581447963800905, 0.576923076923077, 0.574660633484163, 0.572398190045249, 0.570135746606335, 0.567873303167421, 0.565610859728507, 0.563348416289593, 0.561085972850679, 0.558823529411765, 0.556561085972851, 0.554298642533937, 0.552036199095023, 0.554298642533937, 0.552036199095023, 0.549773755656109, 0.547511312217195, 0.54524886877828, 0.540723981900452, 0.538461538461538, 0.536199095022624, 0.53393665158371, 0.531674208144796, 0.529411764705882, 0.524886877828054, \n0.52262443438914, 0.520361990950226, 0.518099547511312, 0.513574660633484, 0.51131221719457, 0.513574660633484, 0.51131221719457, 0.506787330316742, 0.504524886877828, 0.502262443438914, 0.5, 0.497737556561086, 0.5, 0.497737556561086, 0.495475113122172, 0.493212669683258, 0.490950226244344, 0.48868778280543, 0.486425339366516, 0.484162895927602, 0.481900452488688, 0.479638009049774, 0.47737556561086, 0.475113122171946, 0.47737556561086, 0.479638009049774, 0.47737556561086, 0.475113122171946, 0.472850678733032, \n0.470588235294118, 0.468325791855204, 0.46606334841629, 0.463800904977376, 0.461538461538462, 0.459276018099547, 0.457013574660633, 0.452488687782805, 0.450226244343891, 0.447963800904977, 0.445701357466063, 0.443438914027149, 0.441176470588235, 0.438914027149321, 0.436651583710407, 0.434389140271493, 0.432126696832579, 0.429864253393665, 0.425339366515837, 0.423076923076923, 0.420814479638009, 0.418552036199095, 0.416289592760181, 0.418552036199095, 0.418552036199095, 0.416289592760181, 0.414027149321267, \n0.409502262443439, 0.404977375565611, 0.402714932126697, 0.400452488687783, 0.402714932126697, 0.400452488687783, 0.395927601809955, 0.393665158371041, 0.391402714932127, 0.389140271493213, 0.386877828054299, 0.380090497737557, 0.377828054298643, 0.373303167420814, 0.3710407239819, 0.368778280542986, 0.366515837104072, 0.364253393665158, 0.361990950226244, 0.35972850678733, 0.355203619909502, 0.352941176470588, 0.350678733031674, 0.34841628959276, 0.346153846153846, 0.343891402714932, 0.341628959276018, \n0.339366515837104, 0.33710407239819, 0.33710407239819, 0.334841628959276, 0.332579185520362, 0.330316742081448, 0.328054298642534, 0.32579185520362, 0.323529411764706, 0.321266968325792, 0.316742081447964, 0.31447963800905, 0.312217194570136, 0.307692307692308, 0.305429864253394, 0.300904977375566, 0.298642533936652, 0.296380090497738, 0.294117647058824, 0.29185520361991, 0.289592760180996, 0.285067873303167, 0.282805429864253, 0.278280542986425, 0.276018099547511, 0.273755656108597, 0.276018099547511, \n0.273755656108597, 0.271493212669683, 0.269230769230769, 0.266968325791855, 0.262443438914027, 0.260180995475113, 0.257918552036199, 0.255656108597285, 0.253393665158371, 0.248868778280543, 0.246606334841629, 0.244343891402715, 0.242081447963801, 0.237556561085973, 0.235294117647059, 0.233031674208145, 0.230769230769231, 0.228506787330317, 0.223981900452489, 0.219457013574661, 0.217194570135747, 0.214932126696833, 0.212669683257919, 0.208144796380091, 0.205882352941176, 0.203619909502262, 0.201357466063348, \n0.19683257918552, 0.194570135746606, 0.192307692307692, 0.187782805429864, 0.18552036199095, 0.183257918552036, 0.180995475113122, 0.178733031674208, 0.176470588235294, 0.178733031674208, 0.176470588235294, 0.17420814479638, 0.171945701357466, 0.169683257918552, 0.167420814479638, 0.165158371040724, 0.167420814479638, 0.167420814479638, 0.165158371040724, 0.16289592760181)"
# Step 7: Predict the probability of attrition for new data
# You can use the trained h2o model to predict attrition probabilities for new data

# Shutdown the H2O cluster when done
h2o.shutdown()
## Are you sure you want to shutdown the H2O instance running at http://localhost:54321/ (Y/N)?

Prompts: Please update the code to use tidymodels instead of caret and to use h2o model instead of gimnet.

Error Message: ! newdata must be an H2OFrame object Backtrace: 1. h2o::h2o.performance(attrition_gbm, test_data) ChatGPT