Skip to content

remove double intercepts for glmnet models #352

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 3 commits into from
Jul 29, 2020
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
6 changes: 5 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
# parsnip (development version)
# parsnip 0.1.3

* A `glance()` method for `model_fit` objects was added (#325)

* Specific `tidy()` methods for `glmnet` models fit via `parsnip` were created so that the coefficients for the specific fitted `parsnip` model are returned.

## Fixes

* `glmnet` models were fitting two intercepts (#349)

# parsnip 0.1.2

## Breaking Changes
Expand Down
9 changes: 9 additions & 0 deletions R/fit_helpers.R
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,15 @@ xy_xy <- function(object, env, control, target = "none", ...) {
rlang::abort("For classification models, the outcome should be a factor.")
}

encoding_info <-
get_encoding(class(object)[1]) %>%
dplyr::filter(mode == object$mode, engine == object$engine)

remove_intercept <- encoding_info %>% dplyr::pull(remove_intercept)
if (remove_intercept) {
env$x <- env$x[, colnames(env$x) != "(Intercept)", drop = FALSE]
}

# if descriptors are needed, update descr_env with the calculated values
if (requires_descrs(object)) {
data_stats <- get_descr_xy(env$x, env$y)
Expand Down
301 changes: 0 additions & 301 deletions tests/testthat/test_linear_reg_glmnet.R

This file was deleted.

Loading