sich at gmx.de
2008-Feb-03 19:16 UTC
[R] use classificators learned in R in "real-life", e.g. C
Hi there, I am interested in using R for machine learning (supervised classification). Currently, I have been investigating especially the rpart, tree, and randomForest package, and have achieved first results. are there any experiences, how the learned classificators could be used in e.g. C ? in other words, I want to "transfer" the learned predictor from R to C-code. for e.g. rpart, this could of course be done by hand, but, if the tree is sufficiently complex, this is very cumbersome. and for randomForest (which seems to work better for me), this would be even more complex. maybe one way would be to call R from C, but I expect the overhead would be quite high - I need to perform thousands of queries so maybe there is a convenient way to export the classificators to C? thanks a lot, best regards lars --
<sich <at> gmx.de> writes:> I am interested in using R for machine learning (supervised classification). > Currently, I have been investigating especially the rpart, tree, andrandomForest package, and have> achieved first results. > > are there any experiences, how the learned classificators could > be used in e.g. C ? > in other words, I want to "transfer" the learned predictor from R > to C-code.You could use dput to write the representation to a file, and read it from C. Parsing could be nasty, though, so I would prefer to extract the relevant information (e.g. fit$cptable and fit$splits in the rpart example), and write it to a database in numeric form with additional information if required. Another option could be XML (package XML), and using one of the many XML libraries in C(++). Dieter
On Feb 3, 2008 2:16 PM, <sich at gmx.de> wrote:> Hi there, > I am interested in using R for machine learning (supervised classification). > Currently, I have been investigating especially the rpart, tree, and randomForest package, and have achieved first results. > > are there any experiences, how the learned classificators could > be used in e.g. C ? > in other words, I want to "transfer" the learned predictor from R > to C-code. >I don't know of any automated way to do this for those models, but the MARS model in the earth package can export a C-friendly version of the prediction function. See ?format.earth for details. The bagged MARS model in the caret package does the same (see ?format.bagEarth). Max -- Max
Apparently Analagous Threads
- SOLVED: use classificators learned in R in "real-life", e.g. C
- bagged importance estimates in earth problem
- caret: Errors with createGrid for rf (randomForest)
- R 2.12.1 Windows 32bit and 64bit - are numerical differences expected?
- comparing random forests and classification trees