I am trying to change some of the parameters for a h2o
deep learner using mlr
. Similar questions have been asked here and here. However, I'm still confused as to how to change some specific parameters. I have provided a simple example below to illustrate what Im trying to achieve.
If I have some data:
data <- data.frame(
x = rnorm(144),
y = rnorm(144),
z = rnorm(144),
Factor1 = as.factor(rep(c("A", "B"), each = 36)),
Factor2 = as.factor(rep(c(rep("Red", 18), rep("Blue", 18)), 4)),
Response = as.factor(rep(c(rep(1, 11), rep(0, 7), rep(0, 18)), 4))
)
And I set up a h2o
deep learner model, I can change parameters (such as epochs) like so:
library(h2o)
y <- "Response"
x <- names(data[, -6])
h2o.init()
h2o.no_progress()
set.seed(1234)
h2oDL <- h2o.deeplearning(x,
y,
as.h2o(data),
epochs = 50,
nfolds = 3,
score_interval = 1,
stopping_rounds = 5,
stopping_metric = "misclassification",
stopping_tolerance = 1e-3,
)
But what Im trying to do is alter those specific parameters using mlr
. Normally, you could create an mlr
model like so:
library(mlr)
Task <- makeClassifTask(data = data, target = "Response")
Lrn <- makeLearner("classif.h2o.deeplearning", predict.type = "prob")
Mod <-train(Lrn, Task)
I was trying to do something like this:
param_set <- makeParamSet(
makeNumericParam("epochs", default = 50)
)
and then add this when creating the learner, like so:
Task <- makeClassifTask(data = data, target = "Response")
Lrn <- makeLearner("classif.h2o.deeplearning", predict.type = "prob", par.vals = param_set)
Mod <-train(Lrn, Task)
But this throws back an error. Any suggestions as to how I could change the specific parameters (i.e., the ones I'm altering in the h2o.deeplearning
function example above) in mlr
?