Skip to content

Commit

Permalink
init_kfold_refmodel() is only used once, so the code can be simplif…
Browse files Browse the repository at this point in the history
…ied a lot.
  • Loading branch information
fweber144 committed May 24, 2023
1 parent a756eb7 commit 23b274e
Showing 1 changed file with 4 additions and 9 deletions.
13 changes: 4 additions & 9 deletions R/cv_varsel.R
Original file line number Diff line number Diff line change
Expand Up @@ -963,20 +963,15 @@ get_kfold <- function(refmodel, K, verbose) {
folds <- attr(cvfits, "folds")
cvfits <- cvfits$fits
}
cvfits <- lapply(seq_len(K), function(k) {
return(lapply(seq_len(K), function(k) {
cvfit <- cvfits[[k]]
# Add the omitted observation indices for this fold:
cvfit$omitted <- which(folds == k)
# Add the fold index:
cvfit$projpred_k <- k
return(cvfit)
})
return(lapply(cvfits, init_kfold_refmodel, refmodel = refmodel))
}

init_kfold_refmodel <- function(cvfit, refmodel) {
return(list(refmodel = refmodel$cvrefbuilder(cvfit),
omitted = cvfit$omitted))
return(list(refmodel = refmodel$cvrefbuilder(cvfit),
omitted = cvfit$omitted))
}))
}

# ## decide which points to go through in the validation (i.e., which points
Expand Down

0 comments on commit 23b274e

Please sign in to comment.