R/Weka interfaces

Create an R interface to an exisiting Weka learner, or show the available interfaces.

models, interface
make_Weka_associator(method, class = NULL)
make_Weka_classifier(method, class = NULL)
make_Weka_clusterer(method, class = NULL)
a character string giving the fully qualified name of a Weka learner class in JNI notation.
NULL (default), or a character vector giving the names of R classes the objects returned by the interface function should inherit from in addition to the default ones (for representing associators, classifiers, and clusterers).

make_Weka_associator and make_Weka_clusterer create an R function providing an interface to a Weka association learner or a Weka clusterer, respectively. The interface function has formals x and control = NULL, representing the training instances and control options to be employed. Objects created by these interface functions always inherit from classes Weka_associators and Weka_clusterers, respectively, which have at least suitable print methods.

make_Weka_classifier creates an interface function for a Weka classifier, with formals formula, data, subset, na.action, and control = NULL, where the first four have the usual meanings for statistical modeling functions in R, and the last again specifies the control options to be employed by the Weka learner. Objects created by these interfaces always inherit from class Weka_classifier, and have at least suitable print and predict methods.

In addition to creating interface functions, the interfaces are registered (under the name of the Weka class interfaced), which in particular allows the Weka Option Wizard (WOW) to conveniently give on-line information about available control options for the interfaces.

list_Weka_interfaces lists the available interfaces.

It is straightforward to register new interfaces in addition to the ones package RWeka provides by default.

  • make_Weka_associator
  • make_Weka_classifier
  • make_Weka_clusterer
  • list_Weka_interfaces
## Create an interface to Weka's Naive Bayes classifier.
NB <- make_Weka_classifier("weka/classifiers/bayes/NaiveBayes")
## Note that this has a very useful print method:
## And we can use the Weka Option Wizard for finding out more:
## And actually use the interface ...
if(require("e1071", quiet = TRUE)) {
    model <- NB(Class ~ ., data = HouseVotes84)
    predict(model, HouseVotes84[1:10,-1])
    cppredict(model, HouseVotes84[1:10,-1])
## (Compare this to David Meyer's naiveBayes() in package 'e1071'.
Documentation reproduced from package RWeka, version 0.1-0, License: GPL version 2 or newer

Community examples

Looks like there are no examples yet.