Giter Site home page Giter Site logo

Comments (3)

sgvignali avatar sgvignali commented on June 1, 2024

Thanks for reporting the error, I will check it today or tomorrow.

from sdmtune.

sgvignali avatar sgvignali commented on June 1, 2024

The error happens because the function "predict" in the randomForest package expects to have a factor for the "biome" variable, but in the raster object "biome" is a numeric variable.

To avoid this error you can pass an additional argument to the predict function. The predict function for raster dataset implemented in SDMtune uses the predict function implemented in the raster package https://rdrr.io/cran/raster/man/predict.html. You can use the factors argument to pass the levels of the "biome" factor. Here is the code:

f <- list(biome = levels(data@data$biome))
map <- predict(default_model, data = predictors, factors = f)

Note that the factors argument is a named list. You have to match the name with the name of the raster layer, in this case biome.
Be aware that you might have to handle cases in which there are more levels in the raster layer compared to the training dataset (google it and you will find some examples).

from sdmtune.

ManuelSpinola avatar ManuelSpinola commented on June 1, 2024

from sdmtune.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.