tidymodels / censored

Parsnip wrappers for survival models
https://censored.tidymodels.org/
Other
123 stars 12 forks source link

Predict fails on glmnet model fitted through matrix interface #263

Closed hfrick closed 1 year ago

hfrick commented 1 year ago

Something is off in this this glmnet workflow:

library(tidymodels)
library(prodlim)
library(censored)
#> Loading required package: survival

set.seed(1)
sim_tr <- SimSurv(500) %>%
  mutate(event_time = Surv(time, event)) %>%
  select(event_time, X1, X2)
new_x <- sim_tr[1:5, 2:3]

glmn_spec <-
  proportional_hazards(penalty = .01) %>%
  set_engine("glmnet")

glmn_wflow <-
  workflow() %>%
  add_model(glmn_spec) %>%
  add_formula(event_time ~ X1 + X2)

glmn_wflow_fit <- fit(glmn_wflow, data = sim_tr)

predict(glmn_wflow_fit, new_data = new_x)
#> Error in h(simpleError(msg, call)): error in evaluating the argument 'x' in selecting a method for function 'as.matrix': Cholmod error 'X and/or Y have wrong dimensions' at file ../MatrixOps/cholmod_sdmult.c, line 88

Created on 2023-04-26 with reprex v2.0.2

github-actions[bot] commented 1 year ago

This issue has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.