Comments (1)
Hi
This is an interesting feature to be added to p_pdp function. However, I need to think carefully about implementing it to this function based on different ensemble approaches. I will add this implementation to my "todo" list ;)
Meanwhile, you can try to use the data_pdp, which returns a tibble object you can use to plot the curves.
Follow an example
library(terra)
library(dplyr)
library(tidyr)
library(ggplot2)
library(flexsdm)
somevar <- system.file("external/somevar.tif", package = "flexsdm")
somevar <- terra::rast(somevar) # environmental data
names(somevar) <- c("aet", "cwd", "tmx", "tmn")
data(abies)
abies2 <- abies %>%
select(x, y, pr_ab)
abies2 <- sdm_extract(abies2,
x = "x",
y = "y",
env_layer = somevar
)
abies2 <- part_random(abies2,
pr_ab = "pr_ab",
method = c(method = "kfold", folds = 5)
)
svm_t1 <- fit_svm(
data = abies2,
response = "pr_ab",
predictors = c("aet", "cwd", "tmx", "tmn"),
partition = ".part",
thr = c("max_sens_spec")
)
gam_t1 <- fit_gam(
data = abies2,
response = "pr_ab",
predictors = c("aet", "cwd", "tmx", "tmn"),
partition = ".part",
thr = c("max_sens_spec"), k = -1
)
raf_t1 <- fit_raf(
data = abies2,
response = "pr_ab",
predictors = c("aet", "cwd", "tmx", "tmn"),
partition = ".part",
thr = c("max_sens_spec")
)
df_svm <- data_pdp(
model = svm_t1$model,
predictors = c("aet"),
resolution = 100,
resid = TRUE,
projection_data = somevar,
training_data = abies2,
clamping = FALSE
)
df_gam <- data_pdp(
model = gam_t1$model,
predictors = c("aet"),
resolution = 100,
resid = TRUE,
projection_data = somevar,
training_data = abies2,
clamping = FALSE
)
df_raf <- data_pdp(
model = raf_t1$model,
predictors = c("aet"),
resolution = 100,
resid = TRUE,
projection_data = somevar,
training_data = abies2,
clamping = FALSE
)
db_list <- list(SVM = df_svm$pdpdata,
GAM = df_gam$pdpdata,
RAF = df_raf$pdpdata)
db_list <- bind_rows(db_list, .id = "Algorithm")
db_list <- db_list %>% tidyr::spread(Algorithm, Suitability)
# Calculate ensemble
db_list <- db_list %>%
dplyr::rowwise() %>%
mutate(Ensemble = mean(c(GAM, SVM, RAF)))
db_list <- db_list %>%
tidyr::gather("Algorithm", "Suitability", GAM, SVM, RAF, Ensemble)
db_list$`-aet` <- NULL
ggplot(db_list, aes(aet, Suitability)) +
geom_line(aes(color = Algorithm))
ggplot(
db_list %>% dplyr::filter(Algorithm == "Ensemble"),
aes(aet, Suitability)
) +
geom_line(aes(color = Algorithm))
from flexsdm.
Related Issues (20)
- Package download problem HOT 1
- esm_raf not present? HOT 5
- Memory overflow HOT 3
- rlayer argument in sample_background() function
- how to create multi band raster HOT 2
- Predicting PCA HOT 1
- Subscript out of bounds HOT 1
- Evaluation over training dataset (explanatory power)
- occfilt_geo() only works with "x" and "y" columns HOT 1
- rev_jack breaks when v has more than one element
- response curves HOT 1
- correct_colinvar() for pearson method do not return 3 objects, only 2 objects HOT 1
- Allow extra_eval to calculate extrapolation for multiple environments
- Out of memory when using sdm_predict HOT 2
- Survey data bias grid example? HOT 1
- Can´t fit random effects with fit_gam? HOT 1
- bootstrap method using part_random requires presence-absence column to be named "pr_ab"
- part_sblock is using `&&` operators with vectors that have length bigger than 1 and is causing an error
- variable importance HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flexsdm.