Skip to content

Commit dfa7d9a

Browse files
authored
speed up format_classprobs() helper (#934)
1 parent 095499d commit dfa7d9a

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

R/predict.R

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -258,8 +258,14 @@ format_classprobs <- function(x) {
258258
if (!any(grepl("^\\.pred_", names(x)))) {
259259
names(x) <- paste0(".pred_", names(x))
260260
}
261-
x <- as_tibble(x)
262-
x <- purrr::map_dfr(x, rlang::set_names, NULL)
261+
if (!tibble::is_tibble(x)) {
262+
x <- as_tibble(x)
263+
}
264+
265+
for (i in seq_along(x)) {
266+
names(x[[i]]) <- NULL
267+
}
268+
263269
x
264270
}
265271

0 commit comments

Comments
 (0)