Given a Task, creates a model for the learning machine which can be used for predictions on new data.
train(learner, task, subset = NULL, weights = NULL)
learner | (Learner | |
---|---|
task | (Task) |
subset | (integer | logical | |
weights | (numeric) |
(WrappedModel).
training.set = sample(seq_len(nrow(iris)), nrow(iris) / 2) ## use linear discriminant analysis to classify iris data task = makeClassifTask(data = iris, target = "Species") learner = makeLearner("classif.lda", method = "mle") mod = train(learner, task, subset = training.set)#> Error: Please use column names for `x`#> Error in print(mod): object 'mod' not found## use random forest to classify iris data task = makeClassifTask(data = iris, target = "Species") learner = makeLearner("classif.rpart", minsplit = 7, predict.type = "prob") mod = train(learner, task, subset = training.set)#> Error: Please use column names for `x`#> Error in print(mod): object 'mod' not found