I've got a randomForest model object from the R package randomForest and am using the function partialPlot to generate partial dependence plots.
I know that normally one would create these using the full training dataset that went into the randomForest generation. However, I've been playing around to understand the models and have a curious result. When I divide the dataset in two based on values above and below one predictor's mean, then run the partialPlot function separately for each half of the data, the curves look very different. I thought that with a single model, the outcomes should be (at least near) the same. What am I missing here? Reproducible example with a tiny dummy dataset below. Data here: https://drive.google.com/open?id=14kNxo0uP-Ga5hQoOPpDrf-y8mFI030Md
library(randomForest) data = read.csv("data.csv") rf1 = randomForest(data, data$tree, ntree=10) dry = subset(data, data$riv_dst<=mean(data$riv_dst)) wet = subset(data, data$riv_dst>mean(data$riv_dst)) partialPlot(fit.AcrossSites, Wet, mnth_p_) partialPlot(fit.AcrossSites, Dry, mnth_p_)