tidymodels / parsnip

A tidy unified interface to models
https://parsnip.tidymodels.org
Other
586 stars 88 forks source link

sometimes censoring weight columns have names #1023

Closed topepo closed 10 months ago

topepo commented 10 months ago

Discovered in tidymodels/extratests#120

Only when a single row is predicted at a single time:

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

tidymodels_prefer()
theme_set(theme_bw())
options(pillar.advice = FALSE, pillar.min_title_chars = Inf)

set.seed(1)
sim_dat <- prodlim::SimSurv(500) %>%
  mutate(event_time = Surv(time, event)) %>%
  select(event_time, X1, X2)

parsnip_fit <- 
  proportional_hazards() %>% 
  fit(event_time ~ ., sim_dat)

## 

times <- c(2.0, 1.0)

##

res_2_times_2_rows <- 
  augment(parsnip_fit, new_data = head(sim_dat, 2), eval_time = times)
names(res_2_times_2_rows$.pred[[1]]$.weight_censored)
#> NULL

res_2_time_1_row <- 
  augment(parsnip_fit, new_data = head(sim_dat, 1), eval_time = times)
names(res_2_time_1_row$.pred[[1]]$.weight_censored)
#> NULL

res_1_time_2_row <- 
  augment(parsnip_fit, new_data = head(sim_dat, 2), eval_time = times[1])
names(res_1_time_2_row$.pred[[1]]$.weight_censored)
#> NULL

res_1_time_1_row <- 
  augment(parsnip_fit, new_data = head(sim_dat, 1), eval_time = times[1])
names(res_1_time_1_row$.pred[[1]]$.weight_censored)
#> [1] "time"

Created on 2023-11-09 with reprex v2.0.2

hfrick commented 10 months ago

possibly related to https://github.com/tidymodels/extratests/pull/98#discussion_r1196891579

github-actions[bot] commented 9 months 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.