Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@

* A bug was fixed related to the column names generated by `multi_predict()`. The top-level tibble will always have a column named `.pred` and this list column contains tibbles across sub-models. The column names for these sub-model tibbles will have names consistent with `predict()` (which was previously incorrect). See [43c15db](https://github.com/tidymodels/parsnip/commit/43c15db377ea9ef27483ff209f6bd0e98cb830d2).

# [A bug](https://github.com/tidymodels/parsnip/issues/174) was fixed
standardizing the column names of `nnet` class probability predictions.

# parsnip 0.0.3.1

Test case update due to CRAN running extra tests [(#202)](https://github.com/tidymodels/parsnip/issues/202)
Expand Down
2 changes: 1 addition & 1 deletion R/mlp.R
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ nnet_softmax <- function(results, object) {

results <- apply(results, 1, function(x) exp(x)/sum(exp(x)))
results <- t(results)
names(results) <- paste0(".pred_", object$lvl)
colnames(results) <- object$lvl
results <- as_tibble(results)
results
}
Expand Down
8 changes: 8 additions & 0 deletions tests/testthat/test_mlp.R
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,11 @@ test_that('bad input', {
expect_error(translate(mlp(mode = "regression", formula = y ~ x) %>% set_engine()))
})

test_that("nnet_softmax", {
obj <- mlp(mode = 'classification')
obj$lvls <- c("a", "b")
res <- nnet_softmax(matrix(c(.8, .2)), obj)
expect_equal(names(res), obj$lvls)
expect_equal(res$b, 1 - res$a)
})