Learn R Programming

streamMOA (version 1.3-0)

DSClassifier_MOA: DSClassifier_MOA -- MOA-based Stream Classifiers

Description

Interface for MOA-based stream classification methods based on package RMOA.

Usage

DSClassifier_MOA(formula, RMOA_classifier)

# S3 method for DSClassifier_MOA update(object, dsd, n = 1, verbose = FALSE, block = 1000L, ...)

# S3 method for DSClassifier_MOA predict(object, newdata, type = "response", ...)

Value

An object of class DSClassifier_MOA

Arguments

formula

a formula for the classification problem.

RMOA_classifier

a RMOA_classifier object.

object

a DSC object.

dsd

a data stream object.

n

number of data points taken from the stream.

verbose

logical; show progress?

block

process blocks of data to improve speed.

...

further arguments.

newdata

dataframe with the new data.

type

prediction type (see RMOA::predict.MOA_trainedmodel()).

Author

Michael Hahsler

Details

DSClassifier_MOA provides an interface to MOA-based stream classifiers using package RMOA. RMOA provides access to MOAs stream classifiers in the following groups:

  • RMOA::MOA_classification_trees

  • RMOA::MOA_classification_bayes

  • RMOA::MOA_classification_ensemblelearning

Subsequent calls to update() update the current model.

References

Wijffels, J. (2014) Connect R with MOA to perform streaming classifications. https://github.com/jwijffels/RMOA

Bifet A, Holmes G, Pfahringer B, Kranen P, Kremer H, Jansen T, Seidl T (2010). MOA: Massive Online Analysis, a Framework for Stream Classification and Clustering. Journal of Machine Learning Research (JMLR).

Examples

Run this code
if (FALSE) {
library(streamMOA)
library(RMOA)

# create a data stream for the iris dataset
data <- iris[sample(nrow(iris)), ]
stream <- DSD_Memory(data)
stream

# define the stream classifier
cl <- DSClassifier_MOA(
  Species ~ Sepal.Length + Sepal.Width + Petal.Length,
  RMOA::HoeffdingTree()
  )

cl

# update the classifier with 100 points from the stream
update(cl, stream, 100)

# predict the class for the next 50 points
newdata <- get_points(stream, n = 50)
pr <- predict(cl, newdata)
pr

table(pr, newdata$Species)
}

Run the code above in your browser using DataLab