Description Usage Arguments Value Examples
A function that enables the plotting of deep learning predictions on a map.
1 | plot_dl_map(raster_data, keras_model, custom_fun, map_type = "static")
|
raster_data |
A raster dataset containing the occurrence data. |
keras_model |
A trained deep learning model. |
custom_fun |
A custom predict function. |
map_type |
A logical indicating if the map should be static or interactive. |
An interactive leaflet map, showing the species distribution.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | ## Not run:
# download benchmarking data
benchmarking_data <- get_benchmarking_data("Lynx lynx",
limit = 1500)
# transform benchmarking data into a format suitable for deep learning
# if you have previously used a partitioning method you should specify it here
benchmarking_data_dl <- prepare_dl_data(input_data = benchmarking_data$df_data,
partitioning_type = "default")
# perform sanity check on the transformed dataset
# for the training set
head(benchmarking_data_dl$train_tbl)
table(benchmarking_data_dl$y_train_vec)
# for the test set
head(benchmarking_data_dl$test_tbl)
table(benchmarking_data_dl$y_test_vec)
# train neural network
keras_results <- train_dl(benchmarking_data_dl)
# this function is needed for plotting
temp_fun <- function(model, input_data) {
input_data <- tibble::as_tibble(input_data)
data <- recipes::bake(benchmarking_data_dl$rec_obj, new_data = input_data)
v <- keras::predict_proba(object = model, x = as.matrix(data))
as.vector(v)
}
# plot SDM map of neural network predictions
# change the map_type argument if you want a dynamic leaflet map
plot_dl_map(benchmarking_data$raster_data$climate_variables,
keras_results$model,
custom_fun = temp_fun,
map_type = "static")
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.