Skip to content

Commit

Permalink
Update 5.modelingTerra0324_30m_notParallel.R
Browse files Browse the repository at this point in the history
  • Loading branch information
dave-white2 committed Sep 18, 2024
1 parent 74998ba commit 9bb7f6b
Showing 1 changed file with 11 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -180,15 +180,15 @@ set.seed(12)


# set up the train control
fitControl <- trainControl(method = "repeatedcv",
number = 10,
repeats = 5,
p = 0.8, #30% used for test set, 70% used for training set
selectionFunction = 'best',
classProbs = T,
savePredictions = T,
returnResamp = 'final',
search = "random")
fitControl <- trainControl(#method = "repeatedcv",
#number = 10,
#repeats = 5,
p = 0.8, #30% used for test set, 70% used for training set
selectionFunction = 'best',
classProbs = T,
savePredictions = T,
returnResamp = 'final',
search = "random")

# Random Forest - Parallel process

Expand Down Expand Up @@ -232,11 +232,11 @@ rfm <- rfm$finalModel
setwd("~/data/8-vic/results/917")

# predict and writout class raster
terra::predict(rast, rsm, rfm, na.rm=T, filename = "class.tif", overwrite=T, wopt=list(gdal=c("COMPRESS=DEFLATE", "TFW=YES", datatype='INT1U')))
terra::predict(rsm, rfm, na.rm=T, filename = "class.tif", overwrite=T, wopt=list(gdal=c("COMPRESS=DEFLATE", "TFW=YES", datatype='INT1U')))
write.dbf(levels(pred)[[1]], file='class.tif.vat.dbf') # make sure the first part of the file name is exactly the same as the predicted raster

# predict and writeout probability stack
terra::predict(rast, rsm, rfm, na.rm=T, filename = "classProb.tif", type="prob", overwrite=T, wopt=list(gdal=c("COMPRESS=DEFLATE", "TFW=YES", datatype='INT1U')))
terra::predict(rsm, rfm, na.rm=T, filename = "classProb.tif", type="prob", overwrite=T)

gc()

Expand Down

0 comments on commit 9bb7f6b

Please sign in to comment.