Dear, Patrick.

I'm using a workaround to work with RWeka and multicore package. The most
important point is not loading the RWeka package and use the namespace in a
encapsulated function. Take a look on this code:


# C4.5 classifier. Return the prediction for a test dataset.
cl.c45 = function(tran, test) {

    model = RWeka::J48(Species ~ ., tran);
    pred = predict(model, test[,-ncol(test)], type="class");
    names(pred) = row.names(test);
    return(pred);
}


library(multicore)
aux = mclapply(1:1000, function(i) {
    cl.c45(iris, iris)
})

Regards,
Luis








On Tue, Oct 22, 2013 at 7:11 AM, Patrick Connolly <
p_connolly@slingshot.co.nz> wrote:

> On Thu, 17-Oct-2013 at 02:21PM -0300, Luís Paulo F. Garcia wrote:
>
> |> I work very mutch with the packages RWeka and multicore. If you try to
> run
> |> J48 or any tree of RWeka with multicore we hava some errors.
> |>
> |> Example I:
> |>
> |> library(RWeka);
> |> library(multicore);
> |>
> |> mclapply(1:100, function(i) {
> |>     J48(Species ~., iris);
> |> });
> |>
> |>
> |> Output:  "Error in .jcall(o, \"Ljava/lang/Class;\", \"getClass\") : \n
> |> java.lang.ClassFormatError: Incompatible magic value 1347093252 in class
> |> file java/lang/ProcessEnvironment$StringEnvironment\n"
> |>
> |>
> |> Example II:
> |>
> |> library(multicore);
> |>
> |> mclapply(1:100, function(i) {
> |>     RWeka::J48(Species ~., iris);
> |> });
> |>
> |> Output: Erro em .jcall(x$classifier, "S", "toString") :
> |>   RcallMethod: attempt to call a method of a NULL object.
> |>
> |>
> |> Do you know some way to work with parallel processing and RWeka? I tried
> |> MPI and SNOW without success.
>
> Not much help, but I too have not been able to get parallelling RWeka
> to work.  OTOH, what RWeka can do is very fast compared with, say, gbm
> (which does work well with mclapply).
>
> I suspect that it has something to do with how Java is set up, but I
> know nothing about setting up Java.
>
>
>
>
> |>
> |> R version 3.0.2 (2013-09-25) -- "Frisbee Sailing"
> |> Ubuntu 12.04 x64
> |>
> |>
> |> --
> |> Lu?s Paulo Faina Garcia
> |> Engenheiro de Computa??o - Universidade de S?o Paulo
> |> S?o Carlos - SP - Brasil
> |>
> |>      [[alternative HTML version deleted]]
> |>
>
> |> ______________________________________________
> |> R-help@r-project.org mailing list
> |> https://stat.ethz.ch/mailman/listinfo/r-help
> |> PLEASE do read the posting guide
> http://www.R-project.org/posting-guide.html
> |> and provide commented, minimal, self-contained, reproducible code.
>
>
> --
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>    ___    Patrick Connolly
>  {~._.~}                   Great minds discuss ideas
>  _( Y )_                 Average minds discuss events
> (:_~*~_:)                  Small minds discuss people
>  (_)-(_)                              ..... Eleanor Roosevelt
>
> ~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.~.
>



-- 
Luís Paulo Faina Garcia
Engenheiro de Computação - Universidade de São Paulo
São Carlos - SP - Brasil

	[[alternative HTML version deleted]]

