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
Hi Patrick, Thanks for the detailed report. See comments below. On 11 October 2011 05:57, Patrick McCann <patmmccann at gmail.com> wrote: [...]> I am having some trouble using R 2.13.1 for generating a pmml object > of class "c('randomForest.formula', 'randomForest')"[...]> 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.[...]> Error in UseMethod("pmml") : > ?no applicable method for 'pmml' applied to an object of class > "c('randomForest.formula', 'randomForest')"Sorry for the ambiguity there. It tries to say in the paper that "pmml" supports "PMML export of a randomSurvivalForest "rsf" object". It mentions randomForest but does not say it can export randomForest. There is some experimental code for pmml.randomForest but it has not yet been completed.> 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"[...]> ? standardGeneric("size"), <environment>) > 3: size(is.unique) > 2: pmml.rules(rules) > 1: pmml(rules)That's odd. Not quite sure yet what is causing that. On my system it works just fine:> library(pmml) > library(arules) > data(Adult) > rules <- apriori(Adult,parameter = list(supp = 0.5, conf = 0.9, target = "rules"))> pmml(rules)<PMML version="3.2" ...> <Header copyright="Copyright (c) 2011 gjw"...> <Extension name="user" value="gjw" extender="Rattle/PMML"/> <Application name="Rattle/PMML" version="1.2.27"/> <Timestamp>2011-10-11 21:50:40</Timestamp> </Header> [...] My system:> rattleInfo()Rattle: version 2.6.11 cran 2.6.11 R: version 2.13.2 (2011-09-30) (Revision 57111) Sysname: Linux Release: 2.6.38-12-generic Version: #51-Ubuntu SMP Wed Sep 28 14:27:32 UTC 2011 [...] pmml: version 1.2.27 [...] arules: version 1.0-6 I'm using R 2.13.2 - could that be an issue - you have 2.13.1? Regards, Graham