Search code examples
ralgorithmmodelraster

R: How to check which model of an ensemble algorithm has been selected to perform regression?


I am using the R package machisplin (it's not on CRAN) to downscale a satellite image. According to the description of the package:

The machisplin.mltps function simultaneously evaluates different combinations of the six algorithms to predict the input data. During model tuning, each algorithm is systematically weighted from 0-1 and the fit of the ensembled model is evaluated. The best performing model is determined through k-fold cross validation (k=10) and the model that has the lowest residual sum of squares of test data is chosen. After determining the best model algorithms and weights, a final model is created using the full training dataset.

My question is how can I check which model out of the 6 has been selected for the downscaling? To put it differently, when I export the downscaled image, I would like to know which algorithm (out of the 6) has been used to perform the downscaling.

Here is the code:

library(MACHISPLIN)
library(raster)
library(gbm)

evi = raster("path/evi.tif") # covariate
ntl = raster("path/ntl_1600.tif") # raster to be downscaled

##convert one of the rasters to a point dataframe to sample.  Use any raster input.
ntl.points<-rasterToPoints(ntl, 
fun = NULL, 
spatial = FALSE)

##subset only the x and y data
ntl.points<- ntl.points[,1:2]

##Extract values to points from rasters
RAST_VAL<-data.frame(extract(ntl, ntl.points))

##merge sampled data to input
InInterp<-cbind(ntl.points, RAST_VAL)

#run an ensemble machine learning thin plate spline 
interp.rast<-machisplin.mltps(int.values = InInterp, 
                              covar.ras = evi, 
                              smooth.outputs.only = T, 
                              tps = T,
                              n.cores = 4)

#set negative values to 0
interp.rast[[1]]$final[interp.rast[[1]]$final <= 0] <- 0

writeRaster(interp.rast[[1]]$final,
            filename = "path/ntl_splines.tif")

I vied all the output parameters (please refer to Example 2 in the package description) but I couldn't find anything relevant to my question.

I have posted a question on GitHub as well. From here you can download my images.


Solution

  • I think this is a misunderstanding; mahcisplin, isnt testing 6 and gives one. it's trying many ensembles of 6 and its giving one ensemble... or in other words that its the best 'combination of 6 algorithms' that I will get, and not one of 6 algo's chosen.

    It will get something like "a model which is 20% algo1 , 10% algo2 etc. "and not "algo1 is the best and chosen"