-
Notifications
You must be signed in to change notification settings - Fork 11
Expand file tree
/
Copy pathloan-approver-model.R
More file actions
49 lines (40 loc) · 1.58 KB
/
loan-approver-model.R
File metadata and controls
49 lines (40 loc) · 1.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
## Set your working directory
# setwd("/Users/tomk/0xdata/ws/app-consumer-loan")
library(h2o)
h2o.init(nthreads = -1)
print("Loading loan dataset...")
loans <- h2o.importFile(path = "data/loan.csv")
loans$bad_loan <- as.factor(loans$bad_loan)
rand <- h2o.runif(loans, seed = 1234567)
train <- loans[rand$rnd <= 0.8, ]
valid <- loans[rand$rnd > 0.8, ]
myY = "bad_loan"
myX = c("loan_amnt", "longest_credit_length", "revol_util", "emp_length",
"home_ownership", "annual_inc", "purpose", "addr_state", "dti",
"delinq_2yrs", "total_acc", "verification_status", "term")
model <- h2o.gbm(x = myX, y = myY,
training_frame = train, validation_frame = valid,
score_each_iteration = T,
ntrees = 100, max_depth = 5, learn_rate = 0.05,
model_id = "AtrociousLoanModel")
print(model)
# Download generated POJO for model
if (! file.exists("tmp")) {
dir.create("tmp")
}
h2o.download_pojo(model, path = "tmp")
myY = "int_rate"
myX = c("loan_amnt", "longest_credit_length", "revol_util", "emp_length",
"home_ownership", "annual_inc", "purpose", "addr_state", "dti",
"delinq_2yrs", "total_acc", "verification_status", "term")
model <- h2o.gbm(x = myX, y = myY,
training_frame = train, validation_frame = valid,
score_each_iteration = T,
ntrees = 100, max_depth = 5, learn_rate = 0.05,
model_id = "LoanInterestRateModel")
print(model)
# Download generated POJO for model
if (! file.exists("tmp")) {
dir.create("tmp")
}
h2o.download_pojo(model, path = "tmp")