Giter VIP home page Giter VIP logo

blockcv's Introduction

blockCV

Build Status codecov License DOI CRAN version

In a nutshell, package blockCV provides functions to build train and test data sets using three general strategies: buffers, spatial and environmental blocks. It offers several options for how those blocks are constructed and how blocks are allocated to cross-validation folds. It includes a function that applies geostatistical techniques to investigate the existing level of spatial autocorrelation in the chosen predictor variables to inform the choice of block and buffer size. In addition, visualization tools further aid selection of block size and provide understanding of the spread of species data across generated folds.

Installation

To install the package from GitHub use:

# install.packages("devtools")
devtools::install_github("rvalavi/blockCV")

Bsic usage

The following is an example of using spatial block cross-validation for evaluation of species distribution modelling. You can find a comprehensive tutorial in the vignette of the package.

# loading the package
library(blockCV)

# investigate spatial autocorrelation in raster covariates
spatialAutoRange(rasterLayer = awt, # raster file
                 sampleNumber = 5000, # number of cells to be used
                 doParallel = TRUE,
                 showPlots = TRUE)

# spatial blocking by specified range and random assignment
sb <- spatialBlock(speciesData = pa_data,
                   species = "Species",
                   rasterLayer = awt,
                   theRange = 68000, # size of the blocks
                   k = 5,
                   selection = "random",
                   iteration = 250, # find evenly dispersed folds
                   biomod2Format = TRUE)

# explor the generated folds
foldExplorer(sb, awt, pa_data)

Vignette

To see the vignette of the package use:

browseVignettes("blockCV")

The vignette is also available via this link.

Features

Compared to other available packages, blockCV provides more strategies and control over fold generation including:

  • The assignment of the spatial blocks to cross-validation folds can be done in two different ways.
  • The position of the spatial blocks can be modified.
  • The buffering function can account for presence-absence and presence-background data types.
  • The variables are standardized to avoid wide range variables to dominate the environmental blocks
  • Using geostatistical techniques to inform the choice of a suitable distance band by which to separate the data sets

Citation

To cite package ‘blockCV’ in publications use:

Valavi R, Elith J, Lahoz-Monfort JJ, Guillera-Arroita G. blockCV: An r package for generating spatially or environmentally separated folds for k-fold cross-validation of species distribution models. Methods Ecol Evol. 2019; 10:225–232. https://doi.org/10.1111/2041-210X.13107

blockcv's People

Contributors

rvalavi avatar

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.