[R] pmml for random forest & rules

Patrick McCann patmmccann at gmail.com
Mon Oct 10 20:57:36 CEST 2011


Hi,

I am having some trouble using R 2.13.1 for generating a pmml object
of of class "c('randomForest.formula', 'randomForest')"

I see that these methods are available:
> methods(pmml)
 [1] pmml.coxph*    pmml.hclust*   pmml.itemsets* pmml.kmeans*
pmml.ksvm*     pmml.lm*       pmml.multinom* pmml.nnet*
pmml.rpart*
[10] pmml.rsf*      pmml.rules*    pmml.survreg*


However, the R journal 1/1 pg 64 says there should be a method
available ( http://journal.r-project.org/2009-1/RJournal_2009-1_Guazzelli+et+al.pdf
):

Random Forest (and randomSurvivalForest)
— randomForest (Breiman and Cutler. R
port by A. Liaw and M. Wiener, 2009) and randomSurvivalForest
(Ishwaran and Kogalur ,
2009): PMML export of a randomSurvivalForest "rsf" object. This
function gives the user
the ability to export PMML containing the geometry of a forest.

However, if I run these lines of code:

library(randomForest)
(iris.rf<- randomForest(Species ~ ., data=iris))
pmml(iris.rf)

I get this error:

Error in UseMethod("pmml") :
  no applicable method for 'pmml' applied to an object of class
"c('randomForest.formula', 'randomForest')"



Also, if I run these lines of code
data("Adult")
## Mine association rules.
rules <- apriori(Adult,
                 parameter = list(supp = 0.5, conf = 0.9,
                                  target = "rules"))
 pmml(rules)


I get this error:
> pmml(rules)
Error in function (classes, fdef, mtable)  :
  unable to find an inherited method for function "size", for
signature "itemMatrix"


With this traceback:

> traceback()
5: stop("unable to find an inherited method for function \"", fdef at generic,
       "\", for signature ", cnames)
4: function (classes, fdef, mtable)
   {
       methods <- .findInheritedMethods(classes, fdef, mtable)
       if (length(methods) == 1L)
           return(methods[[1L]])
       else if (length(methods) == 0L) {
           cnames <- paste("\"", sapply(classes, as.character),
               "\"", sep = "", collapse = ", ")
           stop("unable to find an inherited method for function \"",
               fdef at generic, "\", for signature ", cnames)
       }
       else stop("Internal error in finding inherited methods; didn't
return a unique method")
   }(list("itemMatrix"), function (object)
   standardGeneric("size"), <environment>)
3: size(is.unique)
2: pmml.rules(rules)
1: pmml(rules)

Thanks,
Patrick McCann



More information about the R-help mailing list