rspatial / terra

R package for spatial data handling https://rspatial.github.io/terra/reference/terra-package.html
GNU General Public License v3.0
543 stars 90 forks source link

How to use cubist model for mapping? #1606

Closed Hongwuliang closed 2 months ago

Hongwuliang commented 2 months ago

cubist

grid <- expand.grid(committees = c(1, 10, 50, 100), neighbors = c(0, 1, 5, 9))

set.seed(123) caret_grid <- train( x = subset(traindata, select = -SOM), y = traindata$SOM, method = "cubist", tuneGrid = grid, trControl = trainControl(method = "cv")) im <- caret::varImp(caret_grid) cub_Predict <- predict(caret_grid, data2) data_cub <- cbind(data2[,1,drop = FALSE],cub_Predict)

pre_cub <- terra::predict(as.data.frame(Bare_land_image), cubist_model, na.rm = F, overwrite = TRUE, cpkgs = "Cubist", cores = 1, filename = "E:/first_paper/landsat9/Result_new/bareland_CN3.tif")

rhijmans commented 2 months ago

This site is not for "how to" questions.