Skip to content

boyanangelov/sdmexplain

Repository files navigation

DOI

sdmexplain

sdmexplain is an R package to make Species Distribution Models more explainable. A preprint of the paper supporting this software is available on biorxiv.

Installation

devtools::install_github("boyanangelov/sdmexplain")

Example

Preparing training data.

occ_data_raw <- sdmbench::get_benchmarking_data("Lynx lynx")
occ_data <- occ_data_raw$df_data
occ_data$label <- as.factor(occ_data$label)

coordinates.df <- rbind(occ_data_raw$raster_data$coords_presence,
                        occ_data_raw$raster_data$background)
occ_data <- cbind(occ_data, coordinates.df)

train_test_split <- rsample::initial_split(occ_data, prop = 0.7)
data.train <- rsample::training(train_test_split)
data.test  <- rsample::testing(train_test_split)

train.coords <- dplyr::select(data.train, c("x", "y"))
data.train$x <- NULL
data.train$y <- NULL

test.coords <- dplyr::select(data.test, c("x", "y"))
data.test$x <- NULL
data.test$y <- NULL

Training SDM.

task <- makeClassifTask(id = "model", data = data.train, target = "label")
lrn <- makeLearner("classif.lda", predict.type = "prob")
mod <- train(lrn, task)

Preparing data for explainability.

explainable_data <- prepare_explainable_data(data.test, mod, test.coords)
processed_plots <- process_lime_plots(explainable_data$explanation)

Plotting explainable map.

plot_explainable_sdm(explainable_data$processed_data,
                     explainable_data$processed_plots)

Cite as: Boyan Angelov. (2018, October 4). boyanangelov/sdmexplain: sdmexplain: An R Package for Making Species Distribution Models More Explainable (Version v0.1.0). Zenodo. http://doi.org/10.5281/zenodo.1445779