Skip to content

Instantly share code, notes, and snippets.

@Keiku
Created January 19, 2017 02:55
Show Gist options
  • Save Keiku/2c640f4aabefc390825faba8f2aca5be to your computer and use it in GitHub Desktop.
Save Keiku/2c640f4aabefc390825faba8f2aca5be to your computer and use it in GitHub Desktop.
iris example with mlr.
library(mlr)
set.seed(123, "L'Ecuyer")
iris.task = classif.task = makeClassifTask(id = "iris-example", data = iris, target = "Species")
resamp = makeResampleDesc("CV", iters = 10L)
lrn = makeLearner("classif.rpart")
control.grid = makeTuneControlGrid()
ps = makeParamSet(
makeDiscreteParam("cp", values = seq(0,0.1,0.01)),
makeDiscreteParam("minsplit", values = c(10,20))
)
getParamSet(lrn)
res = tuneParams(lrn, task = iris.task, resampling = resamp, control = control.grid, par.set = ps, measures = list(acc,timetrain))
opt.grid = as.data.frame(res$opt.path)
print(opt.grid)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment