Open gsatta opened 4 days ago
Hi Gabriele,
Glad to see that you use the new features of biomod2 4.2-6 as RFd ! 🏆
When you run bm_ModelingOptions, you didn't give myBiomodData
. Normally, you have this warning :
Dans .local(strategy, user.val, user.base, tuning.fun, bm.format, :
No bm.format provided. No definition of formula through bm_MakeFormula.
So after, FDA and GBM have failed because they don't have a normal formula, resulting in the error Error in x$formula : oggetto di tipo 'closure' non suddivisibile
.
You just need to add bm.format = myBiomodData
in bm_ModelingOptions or you can give a simple formula to FDA and GBM as you do for GAM or GLM.
I'll see if I can change the code to avoid this problem in the future :wink:
Hope it helps !
Hélène
Hi Hélène thank you for your quickly answer.
After your suggestion, I changed some parts in the code and now I have this new warmings when I run bm_ModelingOptions()
:
warnings:
-=-=-=-=-=-=-=-=-= Build Modeling Options -=-=-=-=-=-=-=-=-=
> FDA options (datatype: binary , package: mda , function: fda )...
> GAM options (datatype: binary , package: mgcv , function: gam )...
> GBM options (datatype: binary , package: gbm , function: gbm )...
> GLM options (datatype: binary , package: stats , function: glm )...
> MAXENT options (datatype: binary , package: MAXENT , function: MAXENT )...
> RF options (datatype: binary , package: randomForest , function: randomForest )...
> RFd options (datatype: binary , package: randomForest , function: randomForest )...
> XGBOOST options (datatype: binary , package: xgboost , function: xgboost )...
-=-=-=-=-=-=-=-=-=-=-=-=-= Done -=-=-=-=-=-=-=-=-=-=-=-=-=
Messaggi di avvertimento:
1: In .bm_ModelingOptions.check.args(data.type = data.type, models = models, :
Only one GAM model can be activated. 'GAM.mgcv.gam' has been set (other available : 'GAM.gam.gam' or 'GAM.mgcv.bam')
2: In .local(strategy, user.val, user.base, tuning.fun, bm.format, :
No bm.format provided. No definition of formula through bm_MakeFormula.
3: In .local(strategy, user.val, user.base, tuning.fun, bm.format, :
No bm.format provided. No definition of formula through bm_MakeFormula.
4: In .local(strategy, user.val, user.base, tuning.fun, bm.format, :
No bm.format provided. No definition of formula through bm_MakeFormula.
5: In .local(strategy, user.val, user.base, tuning.fun, bm.format, :
No bm.format provided. No definition of formula through bm_MakeFormula.
Code used:
allModels <- c("FDA", "GAM", "GBM", "GLM", "MAXENT", "RF", "RFd", "XGBOOST")
user.rf <- list('_allData_allRun' = list(type = 'classification', importance = TRUE,
nodesize = 10, oob.prox = TRUE, ntree = 250,
mtry = 2, maxnodes = 5))
user.maxent <- list('_allData_allRun' = list(visible = TRUE, beta_threshold = 0))
user.XGBOOST <- list('_allData_allRun' = list(objective = "binary:logistic",
params = list(max_depth = 5, eta = 0.2, gamma = 1),
nrounds = 20, subsample = 0.5))
form.GLM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
expl.var = head(myBiomodData@data.env.var),
type = 's_smoother',
interaction.level = 0)
user.GLM <- list('_allData_allRun' = list(formula = form.GLM))
form.GAM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
expl.var = head(myBiomodData@data.env.var),
type = 's_smoother',
interaction.level = 0)
user.GAM <- list('_allData_allRun' = list(algo = 'GAM.mgcv.gam'))
form.GBM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
expl.var = head(myBiomodData@data.env.var),
type = 's_smoother',
interaction.level = 0)
user.GBM <- list('_allData_allRun' = list(formula = form.GBM))
form.FDA <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
expl.var = head(myBiomodData@data.env.var),
type = 's_smoother',
interaction.level = 0)
user.FDA <- list('_allData_allRun' = list(formula = form.FDA))
user.val <- list(RF.binary.randomForest.randomForest = user.rf,
MAXENT.binary.MAXENT.MAXENT = user.maxent,
XGBOOST.binary.xgboost.xgboost = user.XGBOOST,
GLM.binary.stats.glm= user.GLM,
GAM.binary.mgcv.gam= user.GAM,
GBM.binary.gbm.gbm = user.GBM,
FDA.binary.mda.fda = user.FDA)
# starting from bigboss parameters
myBiomodOption <- bm_ModelingOptions(data.type = 'binary',
models = allModels,
strategy = "user.defined",
user.base = 'bigboss',
user.val = user.val)
How can I solve these warnings?
Also I would like to ask, if possible , a little clarification regarding the meaning of _allData_allRun. What exactly does it mean? Does it refer to all data and all model runs?
Thank you very much !
Hello again,
In this case, you didn't specify bm.format
so bm_ModelingOptions cannot create a formula: the warnings appear.
However, you should have add a formula for all the algorithms that need one (for example, RF can deal without it).
So, you can ignore the warnings and it should run without problems.
For _allData_allRun
, I admit it can be confusing at time 😬
_allData_allRun
refers to all your data points without any split for the pseudo-absences or the cross-validation.
If you want to attribute your options for all the models (e.g. PA1_RUN1, PA1_RUN2, ... ), you can use "for_all_datasets".
user.FDA <- list('for_all_datatsets' = list(formula = form.FDA))
However, in this case, you must add bm.format = myBiomodData
in bm_ModelingOptions !
Don't hesitate if it's still not clear !
Hélène
Thank you Hélène !
I just did what you suggested, adding the parameter bm.format = myBiomodData
in the bm_ModelingOptions()
function and changed _allData_allRun
to for_all_datatsets
.
Omitting the warnings, the following error appears:
Error:
-=-=-=-=-=-=-= Build Modeling Options -=-=-=-=-=-=-=
> FDA options (datatype: binary , package: mda , function: fda )...
> GAM options (datatype: binary , package: mgcv , function: gam )...
> GBM options (datatype: binary , package: gbm , function: gbm )...
> GLM options (datatype: binary , package: stats , function: glm )...
> MAXENT options (datatype: binary , package: MAXENT , function: MAXENT )...
> RF options (datatype: binary , package: randomForest , function: randomForest )...
> RFd options (datatype: binary , package: randomForest , function: randomForest )...
> XGBOOST options (datatype: binary , package: xgboost , function: xgboost )...Errore in { : task 1 failed - "task 1 failed - "
names(user.val) must be '_allData_allRun', '_PA1_allRun', '_PA2_allRun', '_PA3_allRun', '_PA4_allRun', '_PA5_allRun', '_PA6_allRun', '_PA7_allRun', '_PA8_allRun', '_PA9_allRun', '_PA10_allRun', '_PA11_allRun', '_PA12_allRun', '_PA13_allRun', '_PA14_allRun', '_PA15_allRun', '_PA16_allRun', '_PA17_allRun', '_PA18_allRun', '_PA19_allRun' or '_PA20_allRun""
In aggiunta: Messaggio di avvertimento:
In .bm_ModelingOptions.check.args(data.type = data.type, models = models, :
Only one GAM model can be activated. 'GAM.mgcv.gam' has been set (other available : 'GAM.gam.gam' or 'GAM.mgcv.bam')
Code:
> allModels <- c("FDA", "GAM", "GBM", "GLM", "MAXENT", "RF", "RFd", "XGBOOST")
> user.rf <- list('for_all_datatsets' = list(type = 'classification', importance = TRUE,
+ nodesize = 10, oob.prox = TRUE, ntree = 250,
+ mtry = 2, maxnodes = 5))
> user.maxent <- list('for_all_datatsets' = list(visible = TRUE, beta_threshold = 0))
> user.XGBOOST <- list('for_all_datatsets' = list(objective = "binary:logistic",
+ params = list(max_depth = 5, eta = 0.2, gamma = 1),
+ nrounds = 20, subsample = 0.5))
> form.GLM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
+ expl.var = head(myBiomodData@data.env.var),
+ type = 's_smoother',
+ interaction.level = 0)
> user.GLM <- list('for_all_datatsets' = list(formula = form.GLM))
> form.GAM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
+ expl.var = head(myBiomodData@data.env.var),
+ type = 's_smoother',
+ interaction.level = 0)
> user.GAM <- list('for_all_datatsets' = list(algo = 'GAM.mgcv.gam'))
> form.GBM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
+ expl.var = head(myBiomodData@data.env.var),
+ type = 's_smoother',
+ interaction.level = 0)
> user.GBM <- list('for_all_datatsets' = list(formula = form.GBM))
> form.FDA <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
+ expl.var = head(myBiomodData@data.env.var),
+ type = 's_smoother',
+ interaction.level = 0)
> user.FDA <- list('for_all_datatsets' = list(formula = form.FDA))
> user.val <- list(RF.binary.randomForest.randomForest = user.rf,
+ MAXENT.binary.MAXENT.MAXENT = user.maxent,
+ XGBOOST.binary.xgboost.xgboost = user.XGBOOST,
+ GLM.binary.stats.glm= user.GLM,
+ GAM.binary.mgcv.gam= user.GAM,
+ GBM.binary.gbm.gbm = user.GBM,
+ FDA.binary.mda.fda = user.FDA)
> # starting from bigboss parameters
> myBiomodOption <- bm_ModelingOptions(data.type = 'binary',
+ models = allModels,
+ strategy = "user.defined",
+ user.base = 'bigboss',
+ user.val = user.val,
+ bm.format = myBiomodData)
Oh I'm sorry: I'm mistyped! 😅
It's "for_all_datasets"
and not "for_all_datatsets" !!
However, you're right: I need to change the error message and add "for_all_datasets"
!
I will push a commit soon !
Hélène
Thank you again Hélène !
Now everything seems to be running except the GBM model. In fact, this error appears: Error:
=-=-=--=-=-=- Phytophthora_PA11_RUN2_GBM
CV: 1
CV: 2
CV: 3
Error in `[.data.frame`(data, flag, model$var.names, drop = FALSE) :
selezionate colonne non definite
*** Error in GBM , calibration failed
*** inherits(g.pred,'try-error')
! Note : Phytophthora_PA11_RUN1_GBM failed!
Why is it selecting undefined columns?
Thank you again !
It's a stranger error. It seems GBM doesn't allow several CV folds if you use a quadratic or s_smoother formula. You can simplify your formula :
form.GBM <- bm_MakeFormula(resp.name = myBiomodData@sp.name,
expl.var = head(myBiomodData@data.env.var),
type = 'simple',
interaction.level = 0)
Or you can deactivate the cv fold inside GBM :
user.GBM <- list('for_all_datasets' = list(formula = form.GBM, cv.folds = 0))
I'll have to investigate more. I don't remember seeing this issue before. In the meantime, I hope these solutions work for you.
Hélène
Context and question Hello everyone, for a few days, when I run the BIOMOD_Modeling() function, the following error appears: in some models:
Error in x$formula : oggetto di tipo 'closure' non suddivisibile
What does it mean? what exactly is the option that can cause this problem?
Thank You
Here is the code and the information:
Session info
Information about myBiomodData