Skip to content

Instantly share code, notes, and snippets.

@fclesio
Created April 30, 2020 08:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fclesio/d06e46613efd73139b002f299cfaacc0 to your computer and use it in GitHub Desktop.
Save fclesio/d06e46613efd73139b002f299cfaacc0 to your computer and use it in GitHub Desktop.
Load data from Layman Brothers and define variables to train
log_debug('Load data')
layman_brothers_url =
"https://raw.githubusercontent.com/fclesio/learning-space/master/Datasets/02%20-%20Classification/default_credit_card.csv"
layman_brothers.hex = h2o.importFile(path = layman_brothers_url,
destination_frame = "layman_brothers.hex")
log_debug('Data loaded')
log_debug('Transform default variable to factor')
layman_brothers.hex$DEFAULT = as.factor(layman_brothers.hex$DEFAULT)
log_debug('Construct test and train sets using sampling')
layman_brothers.split <- h2o.splitFrame(data = layman_brothers.hex,
ratios = 0.90, seed =42)
layman_brothers.train <- layman_brothers.split[[1]]
layman_brothers.test <- layman_brothers.split[[2]]
qty_samples_train <- nrow(layman_brothers.train)
qty_samples_test <- nrow(layman_brothers.test)
log_debug('Training set with {qty_samples_train} records')
log_debug('Test set with {qty_samples_test} records')
log_debug('Set predictor and response variables')
y = "DEFAULT"
x = c(
"LIMIT_BAL"
,"SEX"
,"EDUCATION"
,"MARRIAGE"
,"AGE"
,"PAY_0"
,"PAY_2"
,"PAY_3"
,"PAY_4"
,"PAY_5"
,"PAY_6"
,"BILL_AMT1"
,"BILL_AMT2"
,"BILL_AMT3"
,"BILL_AMT4"
,"BILL_AMT5"
,"BILL_AMT6"
,"PAY_AMT1"
,"PAY_AMT2"
,"PAY_AMT3"
,"PAY_AMT4"
,"PAY_AMT5"
,"PAY_AMT6")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment