ConsBiol-unibern / SDMtune

Performs Variables selection and model tuning for Species Distribution Models (SDMs). It provides also several utilities to display results.
https://consbiol-unibern.github.io/SDMtune/
Other
25 stars 8 forks source link

[Bug]: The package is not accepting new blockCV version (3.0) #24

Closed rogerio-bio closed 1 year ago

rogerio-bio commented 1 year ago

Describe the bug

Using the new version of blockCV to create spatial blocks with cv_spatial, leads to an error when training the model, follows:

Steps to reproduce the bug

library(SDMtune)

# Generate spatial blocks
sp_range <- cv_spatial_autocor(r = predictors, 
                           num_sample = 5000)

spatial_blocks <- cv_spatial(x = pa_data,column = "occ",
                  size = 120798, hexagon = TRUE, 
                  selection = "systematic",
                  iteration = 50)
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          # Train model
model <- train(method = "Maxent", data = data, folds = spatial_blocks, reg = 1, iter = 500, seed = 777)

Session information

model <- train(method = "Maxent", data = data, folds = spatial_blocks, reg = 1, iter = 500, seed = 777)

Error in `.convert_folds()`:
! Folds object format not allowed.
Run `rlang::last_error()` to see where the error occurred.

> spatial_blocks 
[1] "cv_spatial"

> rlang::last_error()
<error/rlang_error>
Error in `.convert_folds()`:
! Folds object format not allowed.
---
Backtrace:
 1. SDMtune::train(...)
 2. SDMtune:::.convert_folds(folds, data)
Run `rlang::last_trace()` to see the full context

Additional information

No response

Reproducible example

sgvignali commented 1 year ago

Thank you for reporting this issue. It should be fixed in the development version.

I will release it on CRAN in the coming days!