babaknaimi / sdm

sdm is an extensible framework to develop species distributions models using individual and community-based approaches, generate ensembles of models, evaluate the models, and predict species potential distributions in space and time.
21 stars 5 forks source link

Infinite processing time of the sdm::sdm() function.. #8

Closed kamaulindhardt closed 3 years ago

kamaulindhardt commented 3 years ago

Hi sdm authors and community,

I am running my sdm model evaluation and it has been taken more than 8 hours now for my computer to run it, and it is still not finished. I have even tried reducing the size of my spatial point data to only have 200 coordinates.

My computer is a MacBook Pro (13-inch, 2018, Four Thunderbolt 3 Ports) Processor: 2.7 GHz Quad-Core Intel Core i7 Memory: 8 GB 2133 MHz LPDDR3

and I am running the function in parallel with all 8 cores.

Let me know if you need more information to answer the question

Any idea why it takes so long?

> d <- sdm::sdmData(type ~. , train = era.af.sp, predictors = bioc, bg = list(method = "gRandom", n = 1000))
> d

class                                 : sdmdata 
=========================================================== 
number of species                     :  1 
species names                         :  type 
number of features                    :  7 
feature names                         :  bio2, bio8, bio9, ... 
type                                  :  Presence-Background 
has independet test data?             :  FALSE 
number of records                     :  1046 
has Coordinates?                      :  TRUE 

> m <- sdm(type ~. , d, method = c("glm", "brt", "rf"), 
+          replications = c("sub", "boot"),
+          test.p = 30,
+          n = 2,
+          parallelSetting = list(ncore = 8, method = "parallel"))
bioc <- exclude(bioc, v)

##########

d <- sdm::sdmData(type ~. , train = era.af.sp, predictors = bioc)
d

# class                                 : sdmdata 
# =========================================================== 
#   number of species                     :  1 
# species names                         :  type 
# number of features                    :  8 
# feature names                         :  bio2, bio8, bio9, ... 
# type                                  :  Presence-Only 
# has independet test data?             :  FALSE 
# number of records                     :  102 
# has Coordinates?                      :  TRUE 

# Making the model

# getmethodNames()

m <- sdm(type ~. , d, method = c("glm", "brt", "rf"), 
         replications = c("sub", "boot"),
         test.p = 30,
         n = 2,
         parallelSetting = list(ncore = 8, method = "parallel"))

m
kamaulindhardt commented 3 years ago

I thourght it might be a good idea to update the sdm package.

I tried updating the sdm package and this is the error message I get..

Restarting R session...

Loading required package: sdm
Loading required package: sp
sdm 1.0-89 (2020-04-22)
Error: package or namespace load failed for ‘sdm’:
 .onAttach failed in attachNamespace() for 'sdm', details:
  call: .sdmOptions$addOption("maxJar", file.exists(jar))
  error: attempt to apply non-function
Error in .requirePackage(package) : unable to find required package ‘sdm’
Loading required package: usdm
Loading required package: raster
> install.packages("sdm")
Error in install.packages : Updating loaded packages
kamaulindhardt commented 3 years ago

Finally worked :) Sorry for the spam!

> library(sdm)
sdm 1.0-89 (2020-04-22)
> m <- sdm::sdm(type ~. , d, method = c("glm", "brt", "rf"), 
+          replications = c("sub", "boot"),
+          test.p = 30,
+          n = 2,
+          parallelSetting = list(ncore = 8, method = "parallel")
+          )
Loading required package: dismo
Loading required package: gbm
Loaded gbm 2.1.8
Loading required package: mda
Loading required package: class
Loaded mda 0.5-2

Loading required package: mgcv
Loading required package: nlme

Attaching package: ‘nlme’

The following object is masked from ‘package:usdm’:

    Variogram

The following object is masked from ‘package:raster’:

    getData

This is mgcv 1.8-33. For overview type 'help("mgcv-package")'.
Loading required package: glmnet
Loading required package: Matrix
Loaded glmnet 4.1-2
Loading required package: earth
Loading required package: Formula
Loading required package: plotmo
Loading required package: plotrix
Loading required package: TeachingDemos
Loading required package: rJava
Loading required package: RSNNS
Loading required package: Rcpp
Loading required package: randomForest
randomForest 4.6-14
Type rfNews() to see new features/changes/bug fixes.
Loading required package: rpart
Loading required package: kernlab

Attaching package: ‘kernlab’

The following objects are masked from ‘package:raster’:

    buffer, rotated

Loading required package: parallel
> m
class                                 : sdmModels 
======================================================== 
number of species                     :  1 
number of modelling methods           :  3 
names of modelling methods            :  glm, brt, rf 
replicate.methods (data partitioning) :  subsampling,bootstrap 
number of replicates (each method)    :  2 
toral number of replicates per model  :  4 (per species) 
test percentage (in subsampling)      :  30 
------------------------------------------
model run success percentage (per species)  :
------------------------------------------
method          type             
---------------------- 
glm        :        100   %
brt        :        100   %
rf         :        100   %

###################################################################
model Mean performance (per species), using test dataset (generated using partitioning):
-------------------------------------------------------------------------------

 ## species   :  type 
=========================

methods    :     AUC     |     COR     |     TSS     |     Deviance 
-------------------------------------------------------------------------
glm        :     0.79    |     0.31    |     0.47    |     0.46     
brt        :     0.87    |     0.48    |     0.64    |     0.43     
rf         :     0.9     |     0.6     |     0.68    |     0.33