Skip to content

Commit

Permalink
catching glmnet elnet errors
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffersonfparil committed Dec 17, 2024
1 parent 44f8605 commit 3a10370
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions R/models.R
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ fn_ridge = function(list_merged, vec_idx_training, vec_idx_validation, other_par
sol = tryCatch(
glmnet::cv.glmnet(x=X_training, y=y_training, alpha=0, nfolds=other_params$n_folds, parallel=FALSE),
error = function(e) {NA})
if (is.na(sol)) {
if (is.na(sol[1])) {
return(list(
list_perf=NA,
df_y_validation=NA,
Expand Down Expand Up @@ -443,7 +443,7 @@ fn_lasso = function(list_merged, vec_idx_training, vec_idx_validation, other_par
sol = tryCatch(
glmnet::cv.glmnet(x=X_training, y=y_training, alpha=1, nfolds=other_params$n_folds, parallel=FALSE),
error = function(e) {NA})
if (is.na(sol)) {
if (is.na(sol[1])) {
return(list(
list_perf=NA,
df_y_validation=NA,
Expand Down Expand Up @@ -596,7 +596,7 @@ fn_elastic_net = function(list_merged, vec_idx_training, vec_idx_validation, oth
sol = tryCatch(
glmnet::cv.glmnet(x=X_training, y=y_training),
error = function(e) {NA})
if (is.na(sol)) {
if (is.na(sol[1])) {
return(list(
list_perf=NA,
df_y_validation=NA,
Expand Down

0 comments on commit 3a10370

Please sign in to comment.