Title: | Connect R with MOA for Massive Online Analysis |
---|---|
Description: | Connect R with MOA (Massive Online Analysis - <https://moa.cms.waikato.ac.nz/>) to build classification models and regression models on streaming data or out-of-RAM data. Also streaming recommendation models are made available. |
Authors: | Jan Wijffels [aut, cre], BNOSAC [cph] |
Maintainer: | Jan Wijffels <[email protected]> |
License: | GPL-3 |
Version: | 1.1.0 |
Built: | 2024-10-30 04:30:28 UTC |
Source: | https://github.com/cran/RMOA |
Reference object of class datastream. This is a generic class which holds general
information about the data stream.
Currently streams are implemented for data in table format (streams of read.table, read.csv, read.csv2,
read.delim, read.delim2), data in RAM (data.frame, matrix), data in ff (on disk).
See the documentation of datastream_file
, datastream_dataframe
, datastream_matrix
,
and datastream_ffdf
description |
The name how the stream is labelled |
args |
a list with arguments used to set up the stream and used in the datastream methods |
A class of type datastream which contains
character with the name how the stream is labelled.
integer with the current state at which the stream will read new instances of data
integer with the number of instances already processed
logical indicating if the stream has finished processing all the instances
list with arguments passed on to the stream when it is created (e.g. arguments of read.table)
## Basic example, showing the general methods available for a datastream object x <- datastream(description = "My own datastream", args = list(a = "TEST")) x str(x) try(x$get_points(x))
## Basic example, showing the general methods available for a datastream object x <- datastream(description = "My own datastream", args = list(a = "TEST")) x str(x) try(x$get_points(x))
Reference object of class datastream_dataframe
.
This is a class which inherits from class datastream
and which can be used to read in a stream
from a data.frame.
data |
a data.frame to extract data from in a streaming way |
A class of type datastream_dataframe
which contains
The data.frame to extract instances from
See datastream
get_points(n)
Get data from a datastream object.
integer, indicating the number of instances to retrieve from the datastream
x <- datastream_dataframe(data=iris) x$get_points(10) x x$get_points(10) x
x <- datastream_dataframe(data=iris) x$get_points(10) x x$get_points(10) x
Reference object of class datastream_ffdf
.
This is a class which inherits from class datastream
and which can be used to read in a stream
from a ffdf from the ff package.
data |
a data.frame to extract data from in a streaming way |
A class of type datastream_ffdf
which contains
The ffdf to extract instances from
See datastream
get_points(n)
Get data from a datastream object.
integer, indicating the number of instances to retrieve from the datastream
## You need to load package ff before you can use datastream_ffdf require(ff) irisff <- as.ffdf(factorise(iris)) x <- datastream_ffdf(data=irisff) x$get_points(10) x x$get_points(10) x
## You need to load package ff before you can use datastream_ffdf require(ff) irisff <- as.ffdf(factorise(iris)) x <- datastream_ffdf(data=irisff) x$get_points(10) x x$get_points(10) x
Reference object of class datastream_file
.
This is a class which inherits from class datastream
and which can be used to read in a stream
from a file. A number of file readers have been implemented, namely
datastream_table
, datastream_csv
, datastream_csv2
,
datastream_delim
, datastream_delim2
.
See the examples.
description |
The name how the stream is labelled |
FUN |
The function to use to read in the file.
Defaults to |
columnnames |
optional character vector of column to overwrite the column names of the data read in with in |
file |
The file to read in. See e.g. |
... |
parameters passed on to |
A class of type datastream_file
which contains
The function to use to read in the file
A connection to the file
A character vector of column names to overwrite the column names with in get_points
See datastream
get_points(n)
Get data from a datastream object.
integer, indicating the number of instances to retrieve from the datastream
read.table
, read.csv
, read.csv2
, read.delim
, read.delim2
mydata <- iris mydata$Species[2:3] <- NA ## Example of a CSV file stream myfile <- tempfile() write.csv(iris, file = myfile, row.names=FALSE, na = "") x <- datastream_csv(file = myfile, na.strings = "") x x$get_points(n=10) x x$get_points(n=10) x x$stop() ## Create your own specific file stream write.table(iris, file = myfile, row.names=FALSE, na = "") x <- datastream_file(description="My file defintion stream", FUN=read.table, file = myfile, header=TRUE, na.strings="") x$get_points(n=10) x x$stop() ## Clean up for CRAN file.remove(myfile)
mydata <- iris mydata$Species[2:3] <- NA ## Example of a CSV file stream myfile <- tempfile() write.csv(iris, file = myfile, row.names=FALSE, na = "") x <- datastream_csv(file = myfile, na.strings = "") x x$get_points(n=10) x x$get_points(n=10) x x$stop() ## Create your own specific file stream write.table(iris, file = myfile, row.names=FALSE, na = "") x <- datastream_file(description="My file defintion stream", FUN=read.table, file = myfile, header=TRUE, na.strings="") x$get_points(n=10) x x$stop() ## Clean up for CRAN file.remove(myfile)
Reference object of class datastream_matrix
.
This is a class which inherits from class datastream
and which can be used to read in a stream
from a matrix.
data |
a matrix to extract data from in a streaming way |
A class of type datastream_matrix
which contains
The matrix to extract instances from
See datastream
get_points(n)
Get data from a datastream object.
integer, indicating the number of instances to retrieve from the datastream
data <- matrix(rnorm(1000*10), nrow = 1000, ncol = 10) x <- datastream_matrix(data=data) x$get_points(10) x x$get_points(10) x
data <- matrix(rnorm(1000*10), nrow = 1000, ncol = 10) x <- datastream_matrix(data=data) x$get_points(10) x x$get_points(10) x
Convert character strings to factors in a dataset
factorise(x, ...)
factorise(x, ...)
x |
object of class data.frame |
... |
other parameters currently not used yet |
a data.frame with the information in x
where character columns are converted to factors
data(iris) str(iris) mydata <- factorise(iris) str(mydata)
data(iris) str(iris) mydata <- factorise(iris) str(mydata)
MOA active learning classification
ActiveClassifier(control = NULL, ...)
ActiveClassifier(control = NULL, ...)
control |
an object of class |
... |
options of parameters passed on to |
An object of class MOA_classifier
which sets up an untrained MOA model,
which can be trained using trainMOA
ctrl <- MOAoptions(model = "ActiveClassifier") mymodel <- ActiveClassifier(control=ctrl) mymodel
ctrl <- MOAoptions(model = "ActiveClassifier") mymodel <- ActiveClassifier(control=ctrl) mymodel
MOA bayesian classification
NaiveBayes(control = NULL, ...) NaiveBayesMultinomial(control = NULL, ...)
NaiveBayes(control = NULL, ...) NaiveBayesMultinomial(control = NULL, ...)
control |
an object of class |
... |
options of parameters passed on to |
An object of class MOA_classifier
which sets up an untrained MOA model,
which can be trained using trainMOA
ctrl <- MOAoptions(model = "NaiveBayes") mymodel <- NaiveBayes(control=ctrl) mymodel
ctrl <- MOAoptions(model = "NaiveBayes") mymodel <- NaiveBayes(control=ctrl) mymodel
MOA classification using ensembles (bagging/boosting/stacking/other)
AccuracyUpdatedEnsemble(control = NULL, ...) AccuracyWeightedEnsemble(control = NULL, ...) ADACC(control = NULL, ...) DACC(control = NULL, ...) LeveragingBag(control = NULL, ...) LimAttClassifier(control = NULL, ...) OCBoost(control = NULL, ...) OnlineAccuracyUpdatedEnsemble(control = NULL, ...) OzaBag(control = NULL, ...) OzaBagAdwin(control = NULL, ...) OzaBagASHT(control = NULL, ...) OzaBoost(control = NULL, ...) OzaBoostAdwin(control = NULL, ...) TemporallyAugmentedClassifier(control = NULL, ...) WeightedMajorityAlgorithm(control = NULL, ...)
AccuracyUpdatedEnsemble(control = NULL, ...) AccuracyWeightedEnsemble(control = NULL, ...) ADACC(control = NULL, ...) DACC(control = NULL, ...) LeveragingBag(control = NULL, ...) LimAttClassifier(control = NULL, ...) OCBoost(control = NULL, ...) OnlineAccuracyUpdatedEnsemble(control = NULL, ...) OzaBag(control = NULL, ...) OzaBagAdwin(control = NULL, ...) OzaBagASHT(control = NULL, ...) OzaBoost(control = NULL, ...) OzaBoostAdwin(control = NULL, ...) TemporallyAugmentedClassifier(control = NULL, ...) WeightedMajorityAlgorithm(control = NULL, ...)
control |
an object of class |
... |
options of parameters passed on to |
An object of class MOA_classifier
which sets up an untrained MOA model,
which can be trained using trainMOA
ctrl <- MOAoptions(model = "OzaBoostAdwin") mymodel <- OzaBoostAdwin(control=ctrl) mymodel
ctrl <- MOAoptions(model = "OzaBoostAdwin") mymodel <- OzaBoostAdwin(control=ctrl) mymodel
MOA classification trees
AdaHoeffdingOptionTree(control = NULL, ...) ASHoeffdingTree(control = NULL, ...) DecisionStump(control = NULL, ...) HoeffdingAdaptiveTree(control = NULL, ...) HoeffdingOptionTree(control = NULL, ...) HoeffdingTree(control = NULL, ...) LimAttHoeffdingTree(control = NULL, ...) RandomHoeffdingTree(control = NULL, ...)
AdaHoeffdingOptionTree(control = NULL, ...) ASHoeffdingTree(control = NULL, ...) DecisionStump(control = NULL, ...) HoeffdingAdaptiveTree(control = NULL, ...) HoeffdingOptionTree(control = NULL, ...) HoeffdingTree(control = NULL, ...) LimAttHoeffdingTree(control = NULL, ...) RandomHoeffdingTree(control = NULL, ...)
control |
an object of class |
... |
options of parameters passed on to |
An object of class MOA_classifier
which sets up an untrained MOA model,
which can be trained using trainMOA
ctrl <- MOAoptions(model = "HoeffdingTree", leafprediction = "MC", removePoorAtts = TRUE, binarySplits = TRUE, tieThreshold = 0.20) hdt <- HoeffdingTree(control=ctrl) hdt hdt <- HoeffdingTree(numericEstimator = "GaussianNumericAttributeClassObserver") hdt
ctrl <- MOAoptions(model = "HoeffdingTree", leafprediction = "MC", removePoorAtts = TRUE, binarySplits = TRUE, tieThreshold = 0.20) hdt <- HoeffdingTree(control=ctrl) hdt hdt <- HoeffdingTree(numericEstimator = "GaussianNumericAttributeClassObserver") hdt
Create a MOA classifier
MOA_classifier(model, control = NULL, ...)
MOA_classifier(model, control = NULL, ...)
model |
character string with a model.
E.g. HoeffdingTree, DecisionStump, NaiveBayes, HoeffdingOptionTree, ...
The list of known models can be obtained by typing RMOA:::.moaknownmodels.
See the examples and |
control |
an object of class |
... |
options of parameters passed on to |
An object of class MOA_classifier
RMOA:::.moaknownmodels ctrl <- MOAoptions(model = "HoeffdingTree", leafprediction = "MC", removePoorAtts = TRUE, binarySplits = TRUE, tieThreshold = 0.20) hdt <- MOA_classifier(model = "HoeffdingTree", control=ctrl) hdt hdt <- MOA_classifier( model = "HoeffdingTree", numericEstimator = "GaussianNumericAttributeClassObserver") hdt
RMOA:::.moaknownmodels ctrl <- MOAoptions(model = "HoeffdingTree", leafprediction = "MC", removePoorAtts = TRUE, binarySplits = TRUE, tieThreshold = 0.20) hdt <- MOA_classifier(model = "HoeffdingTree", control=ctrl) hdt hdt <- MOA_classifier( model = "HoeffdingTree", numericEstimator = "GaussianNumericAttributeClassObserver") hdt
MOA recommendation engines
BRISMFPredictor(control = NULL, ...) BaselinePredictor(control = NULL, ...)
BRISMFPredictor(control = NULL, ...) BaselinePredictor(control = NULL, ...)
control |
an object of class |
... |
options of parameters passed on to |
An object of class MOA_recommender
which sets up an untrained MOA model,
which can be trained using trainMOA
ctrl <- MOAoptions(model = "BRISMFPredictor", features = 10) brism <- BRISMFPredictor(control=ctrl) brism baseline <- BaselinePredictor() baseline
ctrl <- MOAoptions(model = "BRISMFPredictor", features = 10) brism <- BRISMFPredictor(control=ctrl) brism baseline <- BaselinePredictor() baseline
Create a MOA recommendation engine
MOA_recommender(model, control = NULL, ...)
MOA_recommender(model, control = NULL, ...)
model |
character string with a model.
E.g. BRISMFPredictor, BaselinePredictor
The list of known models can be obtained by typing RMOA:::.moaknownmodels.
See the examples and |
control |
an object of class |
... |
options of parameters passed on to |
An object of class MOA_recommender
RMOA:::.moaknownmodels ctrl <- MOAoptions(model = "BRISMFPredictor", features = 10, lRate=0.002) brism <- MOA_recommender(model = "BRISMFPredictor", control=ctrl) brism MOAoptions(model = "BaselinePredictor") baseline <- MOA_recommender(model = "BaselinePredictor") baseline
RMOA:::.moaknownmodels ctrl <- MOAoptions(model = "BRISMFPredictor", features = 10, lRate=0.002) brism <- MOA_recommender(model = "BRISMFPredictor", control=ctrl) brism MOAoptions(model = "BaselinePredictor") baseline <- MOA_recommender(model = "BaselinePredictor") baseline
Create a MOA regressor
MOA_regressor(model, control = NULL, ...)
MOA_regressor(model, control = NULL, ...)
model |
character string with a model.
E.g. AMRulesRegressor, FadingTargetMean, FIMTDD, ORTO, Perceptron, RandomRules, SGD, TargetMean, ...
The list of known models can be obtained by typing RMOA:::.moaknownmodels.
See the examples and |
control |
an object of class |
... |
options of parameters passed on to |
An object of class MOA_regressor
mymodel <- MOA_regressor(model = "FIMTDD") mymodel data(iris) iris <- factorise(iris) irisdatastream <- datastream_dataframe(data=iris) ## Train the model mytrainedmodel <- trainMOA(model = mymodel, Sepal.Length ~ Petal.Length + Species, data = irisdatastream) mytrainedmodel$model summary(lm(Sepal.Length ~ Petal.Length + Species, data = iris)) predict(mytrainedmodel, newdata=iris)
mymodel <- MOA_regressor(model = "FIMTDD") mymodel data(iris) iris <- factorise(iris) irisdatastream <- datastream_dataframe(data=iris) ## Train the model mytrainedmodel <- trainMOA(model = mymodel, Sepal.Length ~ Petal.Length + Species, data = irisdatastream) mytrainedmodel$model summary(lm(Sepal.Length ~ Petal.Length + Species, data = iris)) predict(mytrainedmodel, newdata=iris)
MOA regressors
TargetMean(control = NULL, ...) FadingTargetMean(control = NULL, ...) Perceptron(control = NULL, ...) AMRulesRegressor(control = NULL, ...) FIMTDD(control = NULL, ...) ORTO(control = NULL, ...)
TargetMean(control = NULL, ...) FadingTargetMean(control = NULL, ...) Perceptron(control = NULL, ...) AMRulesRegressor(control = NULL, ...) FIMTDD(control = NULL, ...) ORTO(control = NULL, ...)
control |
an object of class |
... |
options of parameters passed on to |
An object of class MOA_classifier
which sets up an untrained MOA model,
which can be trained using trainMOA
ctrl <- MOAoptions(model = "FIMTDD", DoNotDetectChanges = TRUE, noAnomalyDetection=FALSE, univariateAnomalyprobabilityThreshold = 0.5, verbosity = 5) mymodel <- FIMTDD(control=ctrl) mymodel mymodel <- FIMTDD(ctrlDoNotDetectChanges = FALSE) mymodel
ctrl <- MOAoptions(model = "FIMTDD", DoNotDetectChanges = TRUE, noAnomalyDetection=FALSE, univariateAnomalyprobabilityThreshold = 0.5, verbosity = 5) mymodel <- FIMTDD(control=ctrl) mymodel mymodel <- FIMTDD(ctrlDoNotDetectChanges = FALSE) mymodel
Define the attributes of a dataset (factor levels, numeric or string data) in a MOA setting
MOAattributes(data, ...)
MOAattributes(data, ...)
data |
object of class data.frame |
... |
other parameters currently not used yet |
An object of class MOAmodelAttributes
data(iris) mydata <- factorise(iris) atts <- MOAattributes(data=mydata) atts
data(iris) mydata <- factorise(iris) atts <- MOAattributes(data=mydata) atts
Get and set options for models build with MOA.
MOAoptions(model, ...)
MOAoptions(model, ...)
model |
character string with a model or an object of class |
... |
other parameters specifying the MOA modelling options of each model. See the examples. |
An object of class MOAmodelOptions
.
This is a list with elements:
model: The name of the model
moamodelname: The purpose of the model known by MOA (getPurposeString)
javaObj: a java reference of MOA options
options: a list with options of the MOA model. Each list element contains the Name
of the option, the Purpose
of the option and the current Value
See the examples.
control <- MOAoptions(model = "HoeffdingTree") control MOAoptions(model = "HoeffdingTree", leafprediction = "MC", removePoorAtts = TRUE, binarySplits = TRUE, tieThreshold = 0.20) ## Other models known by RMOA RMOA:::.moaknownmodels ## Classification Trees MOAoptions(model = "AdaHoeffdingOptionTree") MOAoptions(model = "ASHoeffdingTree") MOAoptions(model = "DecisionStump") MOAoptions(model = "HoeffdingAdaptiveTree") MOAoptions(model = "HoeffdingOptionTree") MOAoptions(model = "HoeffdingTree") MOAoptions(model = "LimAttHoeffdingTree") MOAoptions(model = "RandomHoeffdingTree") ## Classification using Bayes rule MOAoptions(model = "NaiveBayes") MOAoptions(model = "NaiveBayesMultinomial") ## Classification using Active learning MOAoptions(model = "ActiveClassifier") ## Classification using Ensemble learning MOAoptions(model = "AccuracyUpdatedEnsemble") MOAoptions(model = "AccuracyWeightedEnsemble") MOAoptions(model = "ADACC") MOAoptions(model = "DACC") MOAoptions(model = "LeveragingBag") MOAoptions(model = "OCBoost") MOAoptions(model = "OnlineAccuracyUpdatedEnsemble") MOAoptions(model = "OzaBag") MOAoptions(model = "OzaBagAdwin") MOAoptions(model = "OzaBagASHT") MOAoptions(model = "OzaBoost") MOAoptions(model = "OzaBoostAdwin") MOAoptions(model = "TemporallyAugmentedClassifier") MOAoptions(model = "WeightedMajorityAlgorithm") ## Regressions MOAoptions(model = "AMRulesRegressor") MOAoptions(model = "FadingTargetMean") MOAoptions(model = "FIMTDD") MOAoptions(model = "ORTO") MOAoptions(model = "Perceptron") MOAoptions(model = "SGD") MOAoptions(model = "TargetMean") ## Recommendation engines MOAoptions(model = "BRISMFPredictor") MOAoptions(model = "BaselinePredictor")
control <- MOAoptions(model = "HoeffdingTree") control MOAoptions(model = "HoeffdingTree", leafprediction = "MC", removePoorAtts = TRUE, binarySplits = TRUE, tieThreshold = 0.20) ## Other models known by RMOA RMOA:::.moaknownmodels ## Classification Trees MOAoptions(model = "AdaHoeffdingOptionTree") MOAoptions(model = "ASHoeffdingTree") MOAoptions(model = "DecisionStump") MOAoptions(model = "HoeffdingAdaptiveTree") MOAoptions(model = "HoeffdingOptionTree") MOAoptions(model = "HoeffdingTree") MOAoptions(model = "LimAttHoeffdingTree") MOAoptions(model = "RandomHoeffdingTree") ## Classification using Bayes rule MOAoptions(model = "NaiveBayes") MOAoptions(model = "NaiveBayesMultinomial") ## Classification using Active learning MOAoptions(model = "ActiveClassifier") ## Classification using Ensemble learning MOAoptions(model = "AccuracyUpdatedEnsemble") MOAoptions(model = "AccuracyWeightedEnsemble") MOAoptions(model = "ADACC") MOAoptions(model = "DACC") MOAoptions(model = "LeveragingBag") MOAoptions(model = "OCBoost") MOAoptions(model = "OnlineAccuracyUpdatedEnsemble") MOAoptions(model = "OzaBag") MOAoptions(model = "OzaBagAdwin") MOAoptions(model = "OzaBagASHT") MOAoptions(model = "OzaBoost") MOAoptions(model = "OzaBoostAdwin") MOAoptions(model = "TemporallyAugmentedClassifier") MOAoptions(model = "WeightedMajorityAlgorithm") ## Regressions MOAoptions(model = "AMRulesRegressor") MOAoptions(model = "FadingTargetMean") MOAoptions(model = "FIMTDD") MOAoptions(model = "ORTO") MOAoptions(model = "Perceptron") MOAoptions(model = "SGD") MOAoptions(model = "TargetMean") ## Recommendation engines MOAoptions(model = "BRISMFPredictor") MOAoptions(model = "BaselinePredictor")
Predict using a MOA classifier, MOA regressor or MOA recommender on a new dataset. \
Make sure the new dataset has the same structure
and the same levels as get_points
returns on the datastream which was used in trainMOA
## S3 method for class 'MOA_trainedmodel' predict(object, newdata, type = "response", transFUN = object$transFUN, na.action = na.fail, ...)
## S3 method for class 'MOA_trainedmodel' predict(object, newdata, type = "response", transFUN = object$transFUN, na.action = na.fail, ...)
object |
an object of class |
newdata |
a data.frame with the same structure and the same levels as used in |
type |
a character string, either 'response' or 'votes' |
transFUN |
a function which is used on |
na.action |
passed on to model.frame when constructing the model.matrix from |
... |
other arguments, currently not used yet |
A matrix of votes or a vector with the predicted class for MOA classifier or MOA regressor. A
## Hoeffdingtree hdt <- HoeffdingTree(numericEstimator = "GaussianNumericAttributeClassObserver") data(iris) ## Make a training set iris <- factorise(iris) traintest <- list() traintest$trainidx <- sample(nrow(iris), size=nrow(iris)/2) traintest$trainingset <- iris[traintest$trainidx, ] traintest$testset <- iris[-traintest$trainidx, ] irisdatastream <- datastream_dataframe(data=traintest$trainingset) ## Train the model hdtreetrained <- trainMOA(model = hdt, Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, data = irisdatastream) ## Score the model on the holdoutset scores <- predict(hdtreetrained, newdata=traintest$testset[, c("Sepal.Length","Sepal.Width","Petal.Length","Petal.Width")], type="response") str(scores) table(scores, traintest$testset$Species) scores <- predict(hdtreetrained, newdata=traintest$testset, type="votes") head(scores) ## Prediction based on recommendation engine require(recommenderlab) data(MovieLense) x <- getData.frame(MovieLense) x$itemid <- as.integer(as.factor(x$item)) x$userid <- as.integer(as.factor(x$user)) x$rating <- as.numeric(x$rating) x <- head(x, 2000) movielensestream <- datastream_dataframe(data=x) movielensestream$get_points(3) ctrl <- MOAoptions(model = "BRISMFPredictor", features = 10) brism <- BRISMFPredictor(control=ctrl) mymodel <- trainMOA(model = brism, rating ~ userid + itemid, data = movielensestream, chunksize = 1000, trace=TRUE) overview <- summary(mymodel$model) str(overview) predict(mymodel, head(x, 10), type = "response") x <- expand.grid(userid=overview$users[1:10], itemid=overview$items) predict(mymodel, x, type = "response")
## Hoeffdingtree hdt <- HoeffdingTree(numericEstimator = "GaussianNumericAttributeClassObserver") data(iris) ## Make a training set iris <- factorise(iris) traintest <- list() traintest$trainidx <- sample(nrow(iris), size=nrow(iris)/2) traintest$trainingset <- iris[traintest$trainidx, ] traintest$testset <- iris[-traintest$trainidx, ] irisdatastream <- datastream_dataframe(data=traintest$trainingset) ## Train the model hdtreetrained <- trainMOA(model = hdt, Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, data = irisdatastream) ## Score the model on the holdoutset scores <- predict(hdtreetrained, newdata=traintest$testset[, c("Sepal.Length","Sepal.Width","Petal.Length","Petal.Width")], type="response") str(scores) table(scores, traintest$testset$Species) scores <- predict(hdtreetrained, newdata=traintest$testset, type="votes") head(scores) ## Prediction based on recommendation engine require(recommenderlab) data(MovieLense) x <- getData.frame(MovieLense) x$itemid <- as.integer(as.factor(x$item)) x$userid <- as.integer(as.factor(x$user)) x$rating <- as.numeric(x$rating) x <- head(x, 2000) movielensestream <- datastream_dataframe(data=x) movielensestream$get_points(3) ctrl <- MOAoptions(model = "BRISMFPredictor", features = 10) brism <- BRISMFPredictor(control=ctrl) mymodel <- trainMOA(model = brism, rating ~ userid + itemid, data = movielensestream, chunksize = 1000, trace=TRUE) overview <- summary(mymodel$model) str(overview) predict(mymodel, head(x, 10), type = "response") x <- expand.grid(userid=overview$users[1:10], itemid=overview$items) predict(mymodel, x, type = "response")
Summary statistics of a MOA classifier
## S3 method for class 'MOA_classifier' summary(object, ...)
## S3 method for class 'MOA_classifier' summary(object, ...)
object |
an object of class |
... |
other arguments, currently not used yet |
the form of the return value depends on the type of MOA model
hdt <- HoeffdingTree(numericEstimator = "GaussianNumericAttributeClassObserver") hdt data(iris) iris <- factorise(iris) irisdatastream <- datastream_dataframe(data=iris) ## Train the model hdtreetrained <- trainMOA(model = hdt, Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, data = irisdatastream) summary(hdtreetrained$model)
hdt <- HoeffdingTree(numericEstimator = "GaussianNumericAttributeClassObserver") hdt data(iris) iris <- factorise(iris) irisdatastream <- datastream_dataframe(data=iris) ## Train the model hdtreetrained <- trainMOA(model = hdt, Species ~ Sepal.Length + Sepal.Width + Petal.Length + Petal.Width, data = irisdatastream) summary(hdtreetrained$model)
Summary statistics of a MOA recommender
## S3 method for class 'MOA_recommender' summary(object, ...)
## S3 method for class 'MOA_recommender' summary(object, ...)
object |
an object of class |
... |
other arguments, currently not used yet |
the form of the return value depends on the type of MOA model
require(recommenderlab) data(MovieLense) x <- getData.frame(MovieLense) x$itemid <- as.integer(as.factor(x$item)) x$userid <- as.integer(as.factor(x$user)) x$rating <- as.numeric(x$rating) x <- head(x, 2000) movielensestream <- datastream_dataframe(data=x) movielensestream$get_points(3) ctrl <- MOAoptions(model = "BRISMFPredictor", features = 10) brism <- BRISMFPredictor(control=ctrl) mymodel <- trainMOA(model = brism, rating ~ userid + itemid, data = movielensestream, chunksize = 1000, trace=TRUE) overview <- summary(mymodel$model) str(overview) predict(mymodel, head(x, 10), type = "response")
require(recommenderlab) data(MovieLense) x <- getData.frame(MovieLense) x$itemid <- as.integer(as.factor(x$item)) x$userid <- as.integer(as.factor(x$user)) x$rating <- as.numeric(x$rating) x <- head(x, 2000) movielensestream <- datastream_dataframe(data=x) movielensestream$get_points(3) ctrl <- MOAoptions(model = "BRISMFPredictor", features = 10) brism <- BRISMFPredictor(control=ctrl) mymodel <- trainMOA(model = brism, rating ~ userid + itemid, data = movielensestream, chunksize = 1000, trace=TRUE) overview <- summary(mymodel$model) str(overview) predict(mymodel, head(x, 10), type = "response")
Summary statistics of a MOA regressor
## S3 method for class 'MOA_regressor' summary(object, ...)
## S3 method for class 'MOA_regressor' summary(object, ...)
object |
an object of class |
... |
other arguments, currently not used yet |
the form of the return value depends on the type of MOA model
## TODO
## TODO
Train a MOA classifier/regressor/recommendation engine on a datastream
trainMOA(model, ...)
trainMOA(model, ...)
model |
an object of class |
... |
other parameters passed on to the methods |
An object of class MOA_trainedmodel which is returned by the methods for the specific model.
See trainMOA.MOA_classifier
, trainMOA.MOA_regressor
, trainMOA.MOA_recommender
trainMOA.MOA_classifier
, trainMOA.MOA_regressor
, trainMOA.MOA_recommender
Train a MOA classifier (e.g. a HoeffdingTree) on a datastream
## S3 method for class 'MOA_classifier' trainMOA(model, formula, data, subset, na.action = na.exclude, transFUN = identity, chunksize = 1000, reset = TRUE, trace = FALSE, options = list(maxruntime = +Inf), ...)
## S3 method for class 'MOA_classifier' trainMOA(model, formula, data, subset, na.action = na.exclude, transFUN = identity, chunksize = 1000, reset = TRUE, trace = FALSE, options = list(maxruntime = +Inf), ...)
model |
an object of class |
formula |
a symbolic description of the model to be fit. |
data |
an object of class |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
na.action |
a function which indicates what should happen when the data contain |
transFUN |
a function which is used after obtaining |
chunksize |
the number of rows to obtain from the |
reset |
logical indicating to reset the |
trace |
logical, indicating to show information on how many datastream chunks are already processed
as a |
options |
a names list of further options. Currently not used. |
... |
other arguments, currently not used yet |
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
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
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
Train a MOA recommender (e.g. a BRISMFPredictor) on a datastream
## S3 method for class 'MOA_recommender' trainMOA(model, formula, data, subset, na.action = na.exclude, transFUN = identity, chunksize = 1000, trace = FALSE, options = list(maxruntime = +Inf), ...)
## S3 method for class 'MOA_recommender' trainMOA(model, formula, data, subset, na.action = na.exclude, transFUN = identity, chunksize = 1000, trace = FALSE, options = list(maxruntime = +Inf), ...)
model |
an object of class |
formula |
a symbolic description of the model to be fit. This should be of the form rating ~ userid + itemid, in that sequence.
These should be columns in the |
data |
an object of class |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
na.action |
a function which indicates what should happen when the data contain |
transFUN |
a function which is used after obtaining |
chunksize |
the number of rows to obtain from the |
trace |
logical, indicating to show information on how many datastream chunks are already processed
as a |
options |
a names list of further options. Currently not used. |
... |
other arguments, currently not used yet |
An object of class MOA_trainedmodel which is a list with elements
model: the updated supplied model
object of class MOA_recommender
call: the matched call
na.action: the value of na.action
terms: the terms
in the model
transFUN: the transFUN argument
MOA_recommender
, datastream_file
, datastream_dataframe
,
datastream_matrix
, datastream_ffdf
, datastream
,
predict.MOA_trainedmodel
require(recommenderlab) data(MovieLense) x <- getData.frame(MovieLense) x$itemid <- as.integer(as.factor(x$item)) x$userid <- as.integer(as.factor(x$user)) x$rating <- as.numeric(x$rating) x <- head(x, 5000) movielensestream <- datastream_dataframe(data=x) movielensestream$get_points(3) ctrl <- MOAoptions(model = "BRISMFPredictor", features = 10) brism <- BRISMFPredictor(control=ctrl) mymodel <- trainMOA(model = brism, rating ~ userid + itemid, data = movielensestream, chunksize = 1000, trace=TRUE) summary(mymodel$model)
require(recommenderlab) data(MovieLense) x <- getData.frame(MovieLense) x$itemid <- as.integer(as.factor(x$item)) x$userid <- as.integer(as.factor(x$user)) x$rating <- as.numeric(x$rating) x <- head(x, 5000) movielensestream <- datastream_dataframe(data=x) movielensestream$get_points(3) ctrl <- MOAoptions(model = "BRISMFPredictor", features = 10) brism <- BRISMFPredictor(control=ctrl) mymodel <- trainMOA(model = brism, rating ~ userid + itemid, data = movielensestream, chunksize = 1000, trace=TRUE) summary(mymodel$model)
Train a MOA regressor (e.g. a FIMTDD) on a datastream
## S3 method for class 'MOA_regressor' trainMOA(model, formula, data, subset, na.action = na.exclude, transFUN = identity, chunksize = 1000, reset = TRUE, trace = FALSE, options = list(maxruntime = +Inf), ...)
## S3 method for class 'MOA_regressor' trainMOA(model, formula, data, subset, na.action = na.exclude, transFUN = identity, chunksize = 1000, reset = TRUE, trace = FALSE, options = list(maxruntime = +Inf), ...)
model |
an object of class |
formula |
a symbolic description of the model to be fit. |
data |
an object of class |
subset |
an optional vector specifying a subset of observations to be used in the fitting process. |
na.action |
a function which indicates what should happen when the data contain |
transFUN |
a function which is used after obtaining |
chunksize |
the number of rows to obtain from the |
reset |
logical indicating to reset the |
trace |
logical, indicating to show information on how many datastream chunks are already processed
as a |
options |
a names list of further options. Currently not used. |
... |
other arguments, currently not used yet |
An object of class MOA_trainedmodel which is a list with elements
model: the updated supplied model
object of class MOA_regressor
call: the matched call
na.action: the value of na.action
terms: the terms
in the model
transFUN: the transFUN argument
MOA_regressor
, datastream_file
, datastream_dataframe
,
datastream_matrix
, datastream_ffdf
, datastream
,
predict.MOA_trainedmodel
mymodel <- MOA_regressor(model = "FIMTDD") mymodel data(iris) iris <- factorise(iris) irisdatastream <- datastream_dataframe(data=iris) irisdatastream$get_points(3) ## Train the model mytrainedmodel <- trainMOA(model = mymodel, Sepal.Length ~ Petal.Length + Species, data = irisdatastream) mytrainedmodel$model irisdatastream$reset() mytrainedmodel <- trainMOA(model = mytrainedmodel$model, Sepal.Length ~ Petal.Length + Species, data = irisdatastream, chunksize = 10, reset=FALSE, trace=TRUE) mytrainedmodel$model
mymodel <- MOA_regressor(model = "FIMTDD") mymodel data(iris) iris <- factorise(iris) irisdatastream <- datastream_dataframe(data=iris) irisdatastream$get_points(3) ## Train the model mytrainedmodel <- trainMOA(model = mymodel, Sepal.Length ~ Petal.Length + Species, data = irisdatastream) mytrainedmodel$model irisdatastream$reset() mytrainedmodel <- trainMOA(model = mytrainedmodel$model, Sepal.Length ~ Petal.Length + Species, data = irisdatastream, chunksize = 10, reset=FALSE, trace=TRUE) mytrainedmodel$model