train: Train a learning algorithm.

Description Usage Arguments Value See Also Examples

View source: R/train.R

Description

Given a Task, creates a model for the learning machine which can be used for predictions on new data.

Usage

1
train(learner, task, subset = NULL, weights = NULL)

Arguments

learner

(Learner | character(1))
The learner. If you pass a string the learner will be created via makeLearner.

task

(Task)
The task.

subset

(integer | logical | NULL)
Selected cases. Either a logical or an index vector. By default NULL if all observations are used.

weights

(numeric)
Optional, non-negative case weight vector to be used during fitting. If given, must be of same length as subset and in corresponding order. By default NULL which means no weights are used unless specified in the task (Task). Weights from the task will be overwritten.

Value

(WrappedModel).

See Also

predict.WrappedModel

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
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)
print(mod)

## 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)
print(mod)

berndbischl/mlr documentation built on Aug. 4, 2018, 2:29 a.m.