[R-sig-Geo] Prediction of multi-target models on stack objects
Hugo Machado Rodrigues
rodr|gue@@m@ch@do@hugo @end|ng |rom gm@||@com
Tue Jun 15 16:25:44 CEST 2021
Dear,
I am trying to adjust prediction models for laboratory-measured electrical
conductivity attributes (EC lab) for depths 0-10, 10-30, and 30-50 cm as a
function of apparent electrical conductivity and apparent magnetic
susceptibility attributes (aEC and aMS) measured by the EM38 sensor using
the two coil distances (aEC 1 and 0.5 m; aMS 1 and 0.5 m) in a saline area.
As laboratory attributes have spatial and depth dependency, I would like to
perform prediction models that consider this condition, and for that, I
decided on multi-output (target) modeling methods.
I am using the Elastic Net Regression approach, and I am using the
following piece of code below:
*# Selecting target variables*
*X <- dados_train %>% select(CE_0_10,CE_10_30,CE_30_50) %>% scale(center
= F, scale = F) %>% as.matrix()*
*# Selecting predicting variablesY <-dados_train
%>% select(CE_1_m,CE_0_5_m,SM_1_m,SM_0_5_m) %>% scale(center = F, scale =
F) %> as.matrix() # Model Building : Elastic Net Regressioncontrol <-
trainControl(method = "repeatedcv", number = 5, repeats = 5, search =
"random", verboseIter = TRUE) # Training Elastic Net Regression
modelelastic_model_glmnet <- train(CE_0_10+CE_10_30+CE_30_50 ~ .,
data = cbind(X, Y), method =
"glmnet", preProcess = c("center", "scale"),
tuneLength = 25, trControl =
control)*
My question is:
*How can I predict using the three output models in the stack containing
the EM38 data layers?*
For this, I am using the code below:
# covariates is a stack object containing the 4 rasters of aEC and aMS data
for the two distances (1 and 0.5 m)
*map_glmnet<-raster::predict(covariates,elastic_model_glmnet,index=c(1:3))*
But that doesn't return me a layer for each target attribute (EC lab for
each depth).
Does anyone have any suggestions?
Best Regards
Hugo
[[alternative HTML version deleted]]
More information about the R-sig-Geo
mailing list