Skip to content

fix cforest_train() #711

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
May 3, 2022
Merged

fix cforest_train() #711

merged 1 commit into from
May 3, 2022

Conversation

hfrick
Copy link
Member

@hfrick hfrick commented May 3, 2022

it didn't return the results of the evaluation in the environment with the weights which caused the cforests tests in censored to fail. Possibly also the reason for tidymodels/bonsai#9

@hfrick hfrick requested a review from simonpcouch May 3, 2022 15:11
@simonpcouch
Copy link
Contributor

Yes, closes tidymodels/bonsai#9!

# pak::pak("tidymodels/parsnip#711")

library(partykit)
#> Loading required package: grid
#> Loading required package: libcoin
#> Loading required package: mvtnorm
library(bonsai)
library(parsnip)
library(testthat)

set.seed(1)
cf_fit_1 <-
  rand_forest(trees = 5) %>%
  set_engine("partykit") %>%
  set_mode("regression") %>%
  fit(mpg ~ ., data = mtcars)

set.seed(1)

pk_fit_1 <- cforest(mpg ~ ., data = mtcars, ntree = 5)

expect_equal(pk_fit_1$fitted, cf_fit_1$fit$fitted)

cf_pred_1 <- predict(cf_fit_1, mtcars)$.pred

pk_pred_1 <- unname(predict(pk_fit_1, mtcars))

expect_equal(pk_pred_1, cf_pred_1)

Created on 2022-05-03 by the reprex package (v2.0.1)

Huzzah!

@simonpcouch simonpcouch merged commit 15d38ca into main May 3, 2022
@simonpcouch simonpcouch deleted the cforest-fix branch May 3, 2022 16:24
@github-actions
Copy link

This pull request has been automatically locked. If you believe you have found a related problem, please file a new issue (with a reprex: https://reprex.tidyverse.org) and link to this issue.

@github-actions github-actions bot locked and limited conversation to collaborators May 18, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants