简体   繁体   中英

Random Forest issues with Importance

I'm trying to construct a random forest for ecological data but keep getting the error

"no applicable method for 'importance' applied to an object of class "logical".

The code I have is:

fit2 <- randomForest(sv ~ salinity + temp + Depthbin +  cdistance + oxygen + 
                      type + diel, data=d.omit, importance(TRUE), ntree=2000)

The variable of interest (sv) is continuous, so I'm not sure if that impacts things. When I remove the importance(TRUE) portion of the code, I can run the random forest but the IncNodePurity values I obtain are ridiculously high (some values over 100,000!!). I'm hoping the importance(TRUE) addition will fix that, but if not, does anyone know of a better way to examine the importance of each variable?

try this instead:

fit2 <- randomForest(sv ~ salinity + temp + Depthbin + cdistance + oxygen + type + diel, data=d.omit, importance=TRUE, ntree=2000)

With importance(fit2) you should be able to see the variable importance.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM