Train a MOA classifier (e.g. a HoeffdingTree) on a datastream
# S3 method for MOA_classifier
trainMOA(model, formula, data, subset,
na.action = na.exclude, transFUN = identity, chunksize = 1000,
reset = TRUE, trace = FALSE, options = list(maxruntime = +Inf), ...)
An object of class MOA_trainedmodel which is a list with elements
model: the updated supplied model
object of class MOA_classifier
call: the matched call
na.action: the value of na.action
terms: the terms
in the model
transFUN: the transFUN argument
an object of class MOA_model
, as returned by MOA_classifier
, e.g.
a HoeffdingTree
a symbolic description of the model to be fit.
an object of class datastream
set up e.g. with datastream_file
,
datastream_dataframe
, datastream_matrix
, datastream_ffdf
or your own datastream.
an optional vector specifying a subset of observations to be used in the fitting process.
a function which indicates what should happen when the data contain NA
s.
See model.frame
for details. Defaults to na.exclude
.
a function which is used after obtaining chunksize
number of rows
from the data
datastream before applying model.frame
. Useful if you want to
change the results get_points
on the datastream
(e.g. for making sure the factor levels are the same in each chunk of processing, some data cleaning, ...).
Defaults to identity
.
the number of rows to obtain from the data
datastream in one chunk of model processing.
Defaults to 1000. Can be used to speed up things according to the backbone architecture of
the datastream.
logical indicating to reset the MOA_classifier
so that it forgets what it
already has learned. Defaults to TRUE.
logical, indicating to show information on how many datastream chunks are already processed
as a message
.
a names list of further options. Currently not used.
other arguments, currently not used yet
MOA_classifier
, datastream_file
, datastream_dataframe
,
datastream_matrix
, datastream_ffdf
, datastream
,
predict.MOA_trainedmodel
hdt <- HoeffdingTree(numericEstimator = "GaussianNumericAttributeClassObserver")
hdt
data(iris)
iris <- factorise(iris)
irisdatastream <- datastream_dataframe(data=iris)
irisdatastream$get_points(3)
mymodel <- trainMOA(model = hdt, Species ~ Sepal.Length + Sepal.Width + Petal.Length,
data = irisdatastream, chunksize = 10)
mymodel$model
irisdatastream$reset()
mymodel <- trainMOA(model = hdt,
Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Length^2,
data = irisdatastream, chunksize = 10, reset=TRUE, trace=TRUE)
mymodel$model
Run the code above in your browser using DataLab