Skip to content

changes for #209 #242

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 2, 2019
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
15 changes: 15 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
# parsnip 0.0.5

## Fixes

* A bug ([#206](https://github.com/tidymodels/parsnip/issues/206) and [#234](https://github.com/tidymodels/parsnip/issues/234)) was fixed that caused an error when predicting with a multinomial `glmnet` model.

## Other Changes

* `glmnet` was removed as a dependency since the new version depends on 3.6.0 or greater. Keeping it would constrain `parsnip` to that same requirement. All `glmnet` tests are run locally.

## New Features

* `nnet` was added as an engine to `multinom_reg()` [#209](https://github.com/tidymodels/parsnip/issues/209)


# parsnip 0.0.4

## New Features
Expand Down
5 changes: 3 additions & 2 deletions R/misc.R
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,8 @@ update_main_parameters <- function(args, param) {
}
param <- param[!has_extra_args]



args <- utils::modifyList(args, param)
}



13 changes: 12 additions & 1 deletion R/multinom_reg.R
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
#' The model can be created using the `fit()` function using the
#' following _engines_:
#' \itemize{
#' \item \pkg{R}: `"glmnet"` (the default)
#' \item \pkg{R}: `"glmnet"` (the default), `"nnet"`
#' \item \pkg{Stan}: `"stan"`
#' \item \pkg{keras}: `"keras"`
#' }
Expand All @@ -49,6 +49,10 @@
#'
#' \Sexpr[results=rd]{parsnip:::show_fit(parsnip:::multinom_reg(), "glmnet")}
#'
#' \pkg{nnet}
#'
#' \Sexpr[results=rd]{parsnip:::show_fit(parsnip:::multinom_reg(), "nnet")}
#'
#' \pkg{spark}
#'
#' \Sexpr[results=rd]{parsnip:::show_fit(parsnip:::multinom_reg(), "spark")}
Expand Down Expand Up @@ -197,6 +201,13 @@ organize_multnet_prob <- function(x, object) {
as_tibble(x)
}

organize_nnet_prob <- function(x, object) {
format_classprobs(x)
}




# ------------------------------------------------------------------------------
# glmnet call stack for multinomial regression using `predict` when object has
# classes "_multnet" and "model_fit" (for class predictions):
Expand Down
82 changes: 82 additions & 0 deletions R/multinom_reg_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -226,3 +226,85 @@ set_pred(
x = quote(as.matrix(new_data)))
)
)


# ------------------------------------------------------------------------------

set_model_engine("multinom_reg", "classification", "nnet")
set_dependency("multinom_reg", "nnet", "nnet")

set_model_arg(
model = "multinom_reg",
eng = "nnet",
parsnip = "penalty",
original = "decay",
func = list(pkg = "dials", fun = "penalty"),
has_submodel = FALSE
)

set_fit(
model = "multinom_reg",
eng = "nnet",
mode = "classification",
value = list(
interface = "formula",
protect = c("formula", "data", "weights"),
func = c(pkg = "nnet", fun = "multinom"),
defaults = list(trace = FALSE)
)
)


set_pred(
model = "multinom_reg",
eng = "nnet",
mode = "classification",
type = "class",
value = list(
pre = NULL,
post = NULL,
func = c(fun = "predict"),
args =
list(
object = quote(object$fit),
newdata = quote(new_data),
type = "class"
)
)
)

set_pred(
model = "multinom_reg",
eng = "nnet",
mode = "classification",
type = "prob",
value = list(
pre = NULL,
post = organize_nnet_prob,
func = c(fun = "predict"),
args =
list(
object = quote(object$fit),
newdata = quote(new_data),
type = "prob"
)
)
)

set_pred(
model = "multinom_reg",
eng = "nnet",
mode = "classification",
type = "raw",
value = list(
pre = NULL,
post = NULL,
func = c(fun = "predict"),
args =
list(
object = quote(object$fit),
newdata = quote(new_data)
)
)
)

46 changes: 23 additions & 23 deletions docs/dev/articles/articles/Classification.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

33 changes: 31 additions & 2 deletions docs/dev/articles/articles/Models.html

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading