-
Notifications
You must be signed in to change notification settings - Fork 0
/
train_super.R
51 lines (45 loc) · 1.33 KB
/
train_super.R
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
50
51
# set caret training parameters
stk_grid = NULL # default tuning parameters
# model specific training parameter
stk_tr = trainControl(
method = 'cv',
number = 4L,
classProbs = TRUE,
savePredictions = "all",
summaryFunction = mnLogLoss,
## summaryFunction = twoClassSummary, # AUC
## summaryFunction = prSummary, # PR-AUC
## summaryFunction = fSummary, # F1
## search = "random",
verboseIter = T,
allowParallel = T,
indexOut = data_folds
)
nnet_grid = expand.grid(size = 3,
decay = 0.1)
sup_x = data.frame(cat = cat_prob,xgb = xgb$prob,ranger = ranger_prob)
sup_y = fytrain
# train the model
set.seed(1)
super_tune = train(x=sup_x, y=sup_y,
weights = weights,
method = "nnet",
trControl = stk_tr,
tuneGrid = nnet_grid,
verbose = T)
## super_tune
super_final = super_tune$finalModel
super_imp = varImp(super_final)
saveRDS(super_final, "super_final.rds")
## train the model
set.seed(1)
super_tune = train(x=sup_x, y=sup_y,
weights = weights,
method = "nnet",
trControl = stk_tr,
tuneGrid = nnet_grid,
verbose = T)
## super_tune
super_final = super_tune$finalModel
super_imp = varImp(super_final)
saveRDS(super_final, "sor_super_final.rds")