ccf
ccf copied to clipboard
CCF - predict from raster brick fail
Hi,
Thank you so much for your contribution!
I used your CCF to train and predict for 5 classes as follows:
ccf <- canonical_correlation_forest(Xtr_ccf, Ytr_ccf, ntree = 100, verbose=TRUE) YpredCCF <- predict(ccf, Xtest_ccf, verbose=TRUE) (1)
Instead of using Xtest_ccf, I would like to predict from a raster brick which have 4 bands (raster brick: taur) to create a classified map (similar to do with random forest):
use predict from raster package YpredCCF <- predict(taur, model=ccf, na.rm=TRUE) (2)
but always get the error (although works for random forest):
Error in setValues(predrast, v) : values must be numeric, integer, logical or factor
Something is wrong with my data or your package will not work with the code 2?
This might be the same issue as for other Random Forest-ish packages. You only need to change a few lines in the raster::predict() function. See this PR: https://github.com/mdsumner/raster-rforge/pull/34