Skip to content

Commit

Permalink
circumvent unnesting of lrSchedule in PLP
Browse files Browse the repository at this point in the history
  • Loading branch information
egillax committed Oct 9, 2023
1 parent 74608ff commit 284cb12
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions R/Estimator.R
Original file line number Diff line number Diff line change
Expand Up @@ -353,12 +353,17 @@ gridCvDeep <- function(mappedData,

trainCache$saveGridSearchPredictions(gridSearchPredictons)
}

browser()
learnSchedules <- lapply(gridSearchPredictons, function(x) {x$param$learnSchedule})
gridSearchPredictons <- lapply(gridSearchPredictons, function(x) {x$param <- x$param[names(x$param) != "learnSchedule"]; x})
# get best para (this could be modified to enable any metric instead of AUC, just need metric input in function)
paramGridSearch <- lapply(gridSearchPredictons, function(x) {
do.call(PatientLevelPrediction::computeGridPerformance, x)
}) # cvAUCmean, cvAUC, param

paramGridSearch <- mapply(function(x, y) {x$hyperSummary$learnRates <- rep(list(unlist(y$LRs)),4) ;
x$param$learnSchedule <- y; x},
paramGridSearch, learnSchedules, SIMPLIFY = FALSE)

optimalParamInd <- which.max(unlist(lapply(paramGridSearch, function(x) x$cvPerformance)))
finalParam <- paramGridSearch[[optimalParamInd]]$param

Expand Down

0 comments on commit 284cb12

Please sign in to comment.