Giter Site home page Giter Site logo

kkougiou / blockcv Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rvalavi/blockcv

0.0 1.0 0.0 4.98 MB

The blockCV package creates spatially or environmentally separated training and testing folds for cross-validation to provide a robust error estimation in spatially structured environments.

R 100.00%

blockcv's Introduction

blockCV

Build Status codecov License GitHub 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")

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:

Roozbeh Valavi, Jane Elith, José Lahoz-Monfort and Gurutzeta Guillera-Arroita (2018). blockCV: Spatial and environmental blocking for k-fold cross-validation. R package version 0.1.0.

Citation will be updated.

blockcv's People

Contributors

rvalavi avatar

Watchers

James Cloos 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.