Skip to content

Commit a82ed40

Browse files
authored
Merge pull request #395 from tidymodels/glmnet-drop-false
Use drop = FALSE for glmnet predictions on single observation
2 parents 97b576e + 32addda commit a82ed40

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

R/linear_reg_data.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,7 @@ set_pred(
168168
args =
169169
list(
170170
object = expr(object$fit),
171-
newx = expr(as.matrix(new_data[, rownames(object$fit$beta)])),
171+
newx = expr(as.matrix(new_data[, rownames(object$fit$beta), drop = FALSE])),
172172
type = "response",
173173
s = expr(object$spec$args$penalty)
174174
)

R/logistic_reg_data.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ set_pred(
187187
args =
188188
list(
189189
object = expr(object$fit),
190-
newx = expr(as.matrix(new_data[, rownames(object$fit$beta)])),
190+
newx = expr(as.matrix(new_data[, rownames(object$fit$beta), drop = FALSE])),
191191
type = "response",
192192
s = expr(object$spec$args$penalty)
193193
)

R/multinom_reg_data.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ set_pred(
6161
args =
6262
list(
6363
object = quote(object$fit),
64-
newx = quote(as.matrix(new_data[, rownames(object$fit$beta[[1]])])),
64+
newx = quote(as.matrix(new_data[, rownames(object$fit$beta[[1]]), drop = FALSE])),
6565
type = "class",
6666
s = quote(object$spec$args$penalty)
6767
)
@@ -80,7 +80,7 @@ set_pred(
8080
args =
8181
list(
8282
object = expr(object$fit),
83-
newx = expr(as.matrix(new_data[, rownames(object$fit$beta[[1]])])),
83+
newx = expr(as.matrix(new_data[, rownames(object$fit$beta[[1]]), drop = FALSE])),
8484
type = "response",
8585
s = expr(object$spec$args$penalty)
8686
)

0 commit comments

Comments
 (0)