Skip to content

Commit 52139aa

Browse files
committed
more tibble naming fxes
1 parent 775b709 commit 52139aa

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

R/logistic_reg_data.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,8 @@ set_pred(
333333
value = list(
334334
pre = NULL,
335335
post = function(x, object) {
336-
x <- as_tibble(x)
337336
colnames(x) <- object$lvl
337+
x <- as_tibble(x)
338338
x
339339
},
340340
func = c(pkg = "keras", fun = "predict_proba"),

R/predict.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ format_num <- function(x) {
184184
return(x)
185185

186186
if (isTRUE(ncol(x) > 1)) {
187-
x <- as_tibble(x)
187+
x <- as_tibble(x, .name_repair = "minimal")
188188
names(x) <- paste0(".pred_", names(x))
189189
} else {
190190
x <- tibble(.pred = x)
@@ -201,8 +201,8 @@ format_class <- function(x) {
201201
}
202202

203203
format_classprobs <- function(x) {
204-
x <- as_tibble(x)
205204
names(x) <- paste0(".pred_", names(x))
205+
x <- as_tibble(x)
206206
x
207207
}
208208

tests/testthat/test_multinom_reg_keras.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ test_that('classification probabilities', {
155155

156156
keras_pred <-
157157
keras::predict_proba(lr_fit$fit, as.matrix(te_dat[, -5])) %>%
158-
as_tibble() %>%
158+
as_tibble(.name_repair = "minimal") %>%
159159
setNames(paste0(".pred_", lr_fit$lvl))
160160

161161
parsnip_pred <- predict(lr_fit, te_dat[, -5], type = "prob")
@@ -172,7 +172,7 @@ test_that('classification probabilities', {
172172

173173
keras_pred <-
174174
keras::predict_proba(plrfit$fit, as.matrix(te_dat[, -5])) %>%
175-
as_tibble() %>%
175+
as_tibble(.name_repair = "minimal") %>%
176176
setNames(paste0(".pred_", lr_fit$lvl))
177177
parsnip_pred <- predict(plrfit, te_dat[, -5], type = "prob")
178178
expect_equal(as.data.frame(keras_pred), as.data.frame(parsnip_pred))

0 commit comments

Comments
 (0)