File: train.Rd

package info (click to toggle)
r-cran-mlr 2.19.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 8,264 kB
  • sloc: ansic: 65; sh: 13; makefile: 5
file content (57 lines) | stat: -rw-r--r-- 1,833 bytes parent folder | download
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
52
53
54
55
56
57
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/train.R
\name{train}
\alias{train}
\title{Train a learning algorithm.}
\usage{
train(learner, task, subset = NULL, weights = NULL)
}
\arguments{
\item{learner}{(\link{Learner} | \code{character(1)})\cr
The learner.
If you pass a string the learner will be created via \link{makeLearner}.}

\item{task}{(\link{Task})\cr
The task.}

\item{subset}{(\link{integer} | \link{logical} | \code{NULL})\cr
Selected cases. Either a logical or an index vector.
By default \code{NULL} if all observations are used.}

\item{weights}{(\link{numeric})\cr
Optional, non-negative case weight vector to be used during fitting.
If given, must be of same length as \code{subset} and in corresponding order.
By default \code{NULL} which means no weights are used unless specified in the task (\link{Task}).
Weights from the task will be overwritten.}
}
\value{
(\link{WrappedModel}).
}
\description{
Given a \link{Task}, creates a model for the learning machine
which can be used for predictions on new data.
}
\examples{
\dontshow{ if (requireNamespace("rpart")) \{ }
\dontshow{ if (requireNamespace("MASS")) \{ }
\dontshow{ if (requireNamespace("rpart")) \{ }
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)
\dontshow{ \} }
\dontshow{ \} }
\dontshow{ \} }
}
\seealso{
\link{predict.WrappedModel}
}