RMOA package for running streaming classifcation & regression models now at CRAN

Last week, we released the RMOA package at CRAN (http://cran.r-project.org/web/packages/RMOA). It is an R package to allow building streaming classification and regression models on top of MOA.
MOA is the acronym of 'Massive Online Analysis' and it is the most popular open source framework for data stream mining which is being developed at the University of Waikato: http://moa.cms.waikato.ac.nz. Our RMOA package interfaces with MOA version 2014.04 and focusses on building, evaluating and scoring streaming classification & regression models on data streams.

Classification & regression models which are possible through RMOA are:

- Classification trees:
  * AdaHoeffdingOptionTree
  * ASHoeffdingTree
  * DecisionStump
  * HoeffdingAdaptiveTree
  * HoeffdingOptionTree
  * HoeffdingTree
  * LimAttHoeffdingTree
  * RandomHoeffdingTree
- Bayesian classification:
  * NaiveBayes
  * NaiveBayesMultinomial
- Active learning classification:
  * ActiveClassifier
- Ensemble (meta) classifiers:
  * Bagging
      + LeveragingBag
      + OzaBag
      + OzaBagAdwin
      + OzaBagASHT
  * Boosting
      + OCBoost
      + OzaBoost
      + OzaBoostAdwin
  * Stacking
      + LimAttClassifier
  * Other
      + AccuracyUpdatedEnsemble
      + AccuracyWeightedEnsemble
      + ADACC
      + DACC
      + OnlineAccuracyUpdatedEnsemble
      + TemporallyAugmentedClassifier
      + WeightedMajorityAlgorithm

- Regression modelling:
  * AMRulesRegressor
  * FadingTargetMean
  * ORTO
  * Perceptron
  * RandomRules
  * SGD (Stochastic Gradient Descent)
  * TargetMean

Interfaces are implemented to model data in standard files (csv, txt, delimited), ffdf data (from the ff package), data.frames and matrices.

Documentation of MOA directed towards RMOA users can be found at http://jwijffels.github.io/RMOA
Examples on the use of RMOA can be found in the documentation, on github at https://github.com/jwijffels/RMOA or e.g. by viewing the showcase at http://bnosac.be/index.php/blog/16-rmoa-massive-online-data-stream-classifications-with-r-a-moa

If you need support on building streaming models on top of your large dataset. Get into contact.

RMOA: Massive online data stream classifications with R & MOA

For those of you who don't know MOA. MOA stands for Massive On-line Analysis and is an open-source framework that allows to build and run experiments of machine learning or data mining on evolving data streams. The website of MOA (http://moa.cms.waikato.ac.nz) indicates it contains machine learning algorithms for classification, regression, clustering, outlier detection and recommendation engines.
For R users who work with a lot of data or encounter RAM issues when building models on large datasets, MOA and in general data streams have some nice features. Namely:
  1. It uses a limited amount of memory. So this means no RAM issues when building models.
  2. Processes one example at a time, and will run over it only once
  3. Works incrementally - so that a model is directly ready to be used for prediction purposes


Unfortunately it is written in Java and not easily accessible for R users to use. For users mostly interested in clustering, the stream package already facilites this (this blog item gave an example when using ff alongside the stream package). In our day-to-day use cases, classification is a more common request. The stream package only allows to do clustering. So hence the decision to make the classification algorithms of MOA easily available to R users as well. For this the RMOA package was created and is available on github (https://github.com/jwijffels/RMOA).
The current features of RMOA are:
  1. Easy to set up data streams on data in RAM (data.frame/matrix), data in files (csv, delimited, flat table) as well as out-of memory data in an ffdf (ff package).
  2. Easy to set up a MOA classification model 
  3. There are 26 classification models available which range from
    1. Classification Trees (AdaHoeffdingOptionTree, ASHoeffdingTree, DecisionStump, HoeffdingAdaptiveTree, HoeffdingOptionTree, HoeffdingTree, LimAttHoeffdingTree, RandomHoeffdingTree)
    2. Bayes Rule (NaiveBayes, NaiveBayesMultinomial)
    3. Ensemble learning
      • Bagging (LeveragingBag, OzaBag, OzaBagAdwin, OzaBagASHT)
      • Boosting (OCBoost, OzaBoost, OzaBoostAdwin)
      • Stacking (LimAttClassifier)
      • Other (AccuracyUpdatedEnsemble, AccuracyWeightedEnsemble, ADACC, DACC, OnlineAccuracyUpdatedEnsemble, TemporallyAugmentedClassifier, WeightedMajorityAlgorithm)
    4. Active learning (ActiveClassifier)
  4. Easy R-familiar interface to train the model on streaming data with a familiar formula interface as in trainMOA(model, formula, data, subset, na.action = na.exclude, ...)
  5. Easy to predict new data alongside the model as in predict(object, newdata, type = "response", ...)
Feel free to use it and we welcome any feedback in your day-to-day RMOA usage experiences at https://github.com/jwijffels/RMOA in order to improve the package. For more documentation on MOA for R users: see http://jwijffels.github.io/RMOA/
An example of R code which constructs a HoeffdingTree and a boosted set of HoeffdingTrees is shown below.
## Installation from github
install_github("jwijffels/RMOA", subdir="RMOAjars/pkg")
install_github("jwijffels/RMOA", subdir="RMOA/pkg")

## HoeffdingTree example
hdt <- HoeffdingTree(numericEstimator = "GaussianNumericAttributeClassObserver")
## Define a stream - e.g. a stream based on a data.frame
iris <- factorise(iris)
irisdatastream <- datastream_dataframe(data=iris)
## Train the HoeffdingTree on the iris dataset
mymodel <- trainMOA(model = hdt, 
  formula = Species ~ Sepal.Length + Sepal.Width + Petal.Length, 
  data = irisdatastream)
## Predict using the HoeffdingTree on the iris dataset
scores <- predict(mymodel, newdata=iris, type="response")
table(scores, iris$Species)
scores <- predict(mymodel, newdata=iris, type="votes")

## Boosted set of HoeffdingTrees
irisdatastream <- datastream_dataframe(data=iris)
mymodel <- OzaBoost(baseLearner = "trees.HoeffdingTree", ensembleSize = 30)
mymodel <- trainMOA(model = mymodel, 
  formula = Species ~ Sepal.Length + Sepal.Width + Petal.Length, 
  data = irisdatastream)
## Predict 
scores <- predict(mymodel, newdata=iris, type="response")
table(scores, iris$Species)
scores <- predict(mymodel, newdata=iris, type="votes")

Air quality, weather analysis & latent feature modelling @RBelgium

rbelgiumlogo v1

Within 2 weeks on Thursday, March 20, The RBelgium R user group is holding its next Regular meeting in Brussels for which this is the schedule:

** Analysis and visualisation of climate data from the atmospheric model ALADIN using the Rfa package! (Rozemien De Troch - Onderzoeksdepartement KMI)

** Probabilistic latent feature analysis with the plfm package (Michel Meulders - Centre for Information Management, Modeling and Simulation, KU Leuven@ HUBrussel)
** AiR Quality Monitoring – An alternative way for data analysis and visualization (Spanu Laurent & Lenartz Fabian - Institut scientifique de service public)

For more information about the event follow this link. Feel free to join.

advanced r programming topics + rapache course

Advanced R programming topics

Similarly as last year, BNOSAC is offering the short course on 'Advanced R programming topics' at the Leuven Statistics Research Center (Belgium). 

The course is now part of FLAMES (Flanders Training Network for Methodology and Statistics) and can be found here http://www.flames-statistics.eu/training/advanced-r-programming-topics. Subscription is no longer possible unless you ask kindly to LStat.

RApache and developing web applications with R as backend

As the demand of courses on R is increasing, we are thinking also about giving a course on RApache and developing web applications with R as a backend. This course will allow you to build applications like this one  http://rweb.stat.ucla.edu/lme4/ or this one http://rweb.stat.ucla.edu/ggplot2/.

BNOSAC has quite some (private) business applications running involving this technology stack and would to share with you it's knowledge. If you are interested in these courses which combine javascript, R and RApache, get in contact with us and send a mail by filling out the form at index.php/contact/get-in-touch. The more people interested, the lower the cost of the course ... .

logo flames


Connect R with Myrrix - Mahout & Cloudera's real-time, scalable recommender system

Myrrix is probably more known by java developers and users of Mahout than R users. This is because most of the times java and R developers live in a different community. 

myrrix logo
If you go to the website of Myrrix (http://myrrix.com), you'll find out that it is a large-scale recommender system which is able to build a recommendation model based on Alternating Least Squares. That technique is a pretty good benchmark model if you tune it well enough to get recommendations to your customers.
It has a setup which allows you to build recommendation models with local data and a setup to build a recommender system based on data in Hadoop - be it on CDH or on another Hadoop stack like HDInsights or your own installation.
Very recently, Cloudera has shown the intention to incorporate Myrrix into it's product offering (see this press release) and this is getting quite some attention.
Recommendation engines are one of the techniques in machine learning which get frequent attention although they are not so frequently used as other statistical techniques like classification or regression.
This is because a recommendation engines most of the time require a lot of processing like deciding on which data to use, handling time-based information, handling new products and products which are no longer sold, making sure the model is up-to-date andsoforth. 
When setting up a recommendation engine, business users also want to compare their behaviour to other business-driven or other data-driven logic. In these initial phases of a project, allowing statisticians and data scientists to use their language of choice to communicate with, test and evaluate the recommendation engine is key.
myrrix r
To allow this, we have created an interface between R and Myrrix, containing 2 packages which are currently available on github (https://github.com/jwijffels/Myrrix-R-interface). It allows R users to build, finetune and evaluate the recommendation engine as well as retrieve recommendations. Future users of Cloudera might as well be interested in this, once Myrrix gets incorporated into their product offering.
Myrrix deploys a recommender engine technique based on large, sparse matrix factorization. From input data, it learns a small number of "features" that best explain users' and items' observed interactions. This same basic idea goes by many names in machine learning, like principal component analysist or latent factor analysis. Myrrix uses a modified version of an Alternating Least Squares algorithm to factor matrices. More information can be found here: http://www.slideshare.net/srowen/big-practical-recommendations-with-alternating-least-squares and at the Myrrix website.
So if you are interested in setting up a recommendation engine for your application or if you want to improve your existing recommendation toolkit, contact us.
If you are an R user and only interested in the code on how to build a recommendation model and retrieve recommendations, here it is. The packages will be pushed to CRAN soon.
# To start up building recommendation engines, install the R packages Myrrixjars and Myrrix as follows.

install_github("Myrrix-R-interface", "jwijffels", subdir="/Myrrixjars/pkg")
install_github("Myrrix-R-interface", "jwijffels", subdir="/Myrrix/pkg")

## The following example shows the basic usage on how to use Myrrix to build a local recommendation 
## engine. It uses the audioscrobbler data available on the Myrrix website.

## Download example dataset
inputfile <- file.path(tempdir(), "audioscrobbler-data.subset.csv.gz")
download.file(url="http://dom2bevkhhre1.cloudfront.net/audioscrobbler-data.subset.csv.gz", destfile = inputfile)

## Set hyperparameters
setMyrrixHyperParameters(params=list(model.iterations.max = 2, model.features=10, model.als.lambda=0.1))
x <- getMyrrixHyperParameters(parameters=c("model.iterations.max","model.features","model.als.lambda"))

## Build a model which will be stored in getwd() and ingest the data file into it
recommendationengine <- new("ServerRecommender", localInputDir=getwd())
ingest(recommendationengine, inputfile)

## Get all users/items and score alongside the recommendation model
items <- getAllItemIDs(recommendationengine)
users <- getAllUserIDs(recommendationengine)
estimatePreference(recommendationengine, userID=users[1], itemIDs=items[1:20])
estimatePreference(recommendationengine, userID=users[10], itemIDs=items)
mostPopularItems(recommendationengine, howMany=10L)
recommend(recommendationengine, userID=users[5], howMany=10L)