1
1
2
- predict_model <- function (split , workflow , grid , metrics , submodels = NULL ,
2
+ predict_model <- function (split , workflow , grid , metrics , submodels = NULL ,
3
3
metrics_info , eval_time = NULL ) {
4
4
5
5
model <- extract_fit_parsnip(workflow )
@@ -102,31 +102,21 @@ predict_model <- function(split, workflow, grid, metrics, submodels = NULL,
102
102
res <- dplyr :: full_join(res , case_weights , by = " .row" )
103
103
}
104
104
}
105
+
106
+
107
+ res <- maybe_add_ipcw(res , model , types )
108
+
105
109
if (! tibble :: is_tibble(res )) {
106
110
res <- tibble :: as_tibble(res )
107
111
}
108
- # maybe_add_ipcw(res, model, eval_time, types)
109
112
res
110
113
}
111
114
112
- # TODO do we need this?
113
- # res <- tibble::as_tibble(res)
114
-
115
- }
116
-
117
- maybe_add_ipcw <- function (.data , model , eval_time , types ) {
115
+ maybe_add_ipcw <- function (.data , model , types ) {
118
116
if (! any(types == " survival" )) {
119
117
return (.data )
120
118
}
121
- res <-
122
- tidyr :: unnest(.data , cols = .pred ) %> %
123
- dplyr :: rename(eval_time = .time ) %> %
124
- dplyr :: full_join(
125
- # TODO is the outcome name enforced or the original name?
126
- parsnip :: .censoring_weights_graf(model , .data , eval_time = eval_time ),
127
- by = c(" .row" , " eval_time" )
128
- )
129
- res
119
+ parsnip :: .censoring_weights_graf(model , .data )
130
120
}
131
121
132
122
predict_wrapper <- function (model , new_data , type , eval_time , subgrid = NULL ) {
@@ -147,7 +137,7 @@ predict_wrapper <- function(model, new_data, type, eval_time, subgrid = NULL) {
147
137
# Add in censored regression evaluation times (if needed)
148
138
has_type <- type %in% c(" survival" , " hazard" )
149
139
if (model $ spec $ mode == " censored regression" & ! is.null(eval_time ) & has_type ) {
150
- cl <- rlang :: call_modify(cl , time = eval_time )
140
+ cl <- rlang :: call_modify(cl , eval_time = eval_time )
151
141
}
152
142
153
143
# When there are sub-models:
0 commit comments