ccf icon indicating copy to clipboard operation
ccf copied to clipboard

CCF - predict from raster brick fail

Open hnthang opened this issue 6 years ago • 1 comments

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?

hnthang avatar Sep 19 '18 12:09 hnthang

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

mwip avatar Jun 19 '19 06:06 mwip