November 2016
Beginner to intermediate
959 pages
43h 46m
English
We provide the framework of the code to perform leave-one-out-cross-validation for linear regression. You should be able to easily adapt this code for any other regression technique. The rationale and explanation presented under the previous recipe Performing k-fold cross-validation apply to this one as well.
To perform leave-one-out-cross-validation (LOOCV) to limit overfitting, follow the steps below:
> bh <- read.csv("BostonHousing.csv")1 rdacb.loocv.reg <- function(df) { 2 mean.sqr.errs <- sapply(1:nrow(df), rdacb.loocv.reg.iter, df) 3 list("mean_sqr_errs"= mean.sqr.errs, "overall_mean_sqr_err" ...Read now
Unlock full access