我正在使用R中随机森林的回归模型,我发现参数corr.bias根据手册是“实验性的”,我的数据是非线性的,我只是想知道将此参数设置为true是否可以增强结果,加上我不确切知道它对非线性数据是如何工作的,所以我真的很感激,如果有人可以向我解释这个校正偏差在随机森林包中是如何工作的,以及它是否可以增强我的回归模型。
答案 0 :(得分:3)
简短的回答是,它基于对实际值和拟合值的线性回归进行简单校正。
来自regrf.c
:
/* Do simple linear regression of y on yhat for bias correction. */
if (*biasCorr) simpleLinReg(nsample, yptr, y, coef, &errb, nout);
,该功能的前几行简单:
void simpleLinReg(int nsample, double *x, double *y, double *coef,
double *mse, int *hasPred) {
/* Compute simple linear regression of y on x, returning the coefficients,
the average squared residual, and the predicted values (overwriting y). */
因此,当您使用corr.bias = TRUE
拟合回归随机林时,返回的模型对象将包含coef
元素,该元素将只是线性回归中的两个系数。
然后当你拨打predict.randomForest
时会发生这种情况:
## Apply bias correction if needed.
yhat <- rep(NA, length(rn))
names(yhat) <- rn
if (!is.null(object$coefs)) {
yhat[keep] <- object$coefs[1] + object$coefs[2] * ans$ypred
}
数据的非线性特性可能不一定相关,但如果拟合值与实际值之间的关系与线性相差很远,偏差校正可能会非常差。
您可以随时调整模型,然后自己绘制拟合值与实际值,并查看基于线性回归的校正是否有帮助。