harrysouthworth / gbm

Gradient boosted models
Other
106 stars 27 forks source link

Error in running of the gbm package #35

Closed clebersfluz closed 9 years ago

clebersfluz commented 9 years ago

Good morning.

I am phd student at university of São Paulo in Brazil.

I am running the algorithms of the biomod2 in parallel, but the execution of the GBM algorithm is presenting failed.

I am using the package "Snowfall" to run the algorithms of the biomod2 in parallel, but a execution of the algorithm GBM presenting failed.

This code:

model.sp <- try(gbm(formula = makeFormula(colnames(Data)[1],head(Data)          [,expl_var_names,drop=FALSE], 'simple',0),
                    data = Data[calibLines,,drop=FALSE],
                    distribution = Options@GBM$distribution,
                    var.monotone = rep(0, length = ncol(Data)-2), # -2 because of removing of sp and weights
                    weights = Yweights,
                    interaction.depth = Options@GBM$interaction.depth,
                    n.minobsinnode = Options@GBM$n.minobsinnode,
                    shrinkage = Options@GBM$shrinkage,
                    bag.fraction = Options@GBM$bag.fraction,
                    train.fraction = Options@GBM$train.fraction,
                    n.trees = Options@GBM$n.trees,
                    verbose = Options@GBM$verbose,
                    #class.stratify.cv = Options@GBM$class.stratify.cv,
                    cv.folds = Options@GBM$cv.folds))#,
                    #n.cores=1)) ## to prevent from parallel issues

The model.sp presentig this message:

<simpleError in x[i]: object of type 'closure' is not subsettable

Error in gbmCluster(n.cores) : could not find function \"detectCores\"\n" attr(,"class") [1] "try-error" attr(,"condition") <simpleError in gbmCluster(n.cores): could not find function "detectCores">

I don't know what.

Do you help me?

Thank you

harrysouthworth commented 9 years ago

Just replied by email, not realizing it was via GitHub.

The call to detectCores is in gbmCluster. I just edited it to parallel::detectCores. I haven't done any testing.

An alternative is to provide n.cores so that detectCores never gets called