tidymodels / hardhat

Construct Modeling Packages
https://hardhat.tidymodels.org
Other
103 stars 17 forks source link

error when adding new role to feature #120

Closed EmilHvitfeldt closed 4 years ago

EmilHvitfeldt commented 4 years ago

I took a look at https://github.com/tidymodels/tune/issues/143 and the issue seems to happen once you reach hardhat. Basically, if you add a second role to a feature, you get an extras list, which when used in blueprint$forge$process does name-repair which then makes it so it can't find the variables.

Below is a pretty minimal example of what happens inside the https://github.com/tidymodels/tune/issues/143 example

library(recipes)
#> Loading required package: dplyr
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
#> 
#> Attaching package: 'recipes'
#> The following object is masked from 'package:stats':
#> 
#>     step
library(hardhat)

rec <- recipe(Species ~ ., iris) %>%
  step_pca(all_predictors()) %>%
  # Add new role to feature
  add_role(Sepal.Length, new_role = "test")

iris_recipe <- mold(rec, iris)

cleaned <- iris_recipe$blueprint$forge$clean(
  blueprint = iris_recipe$blueprint, 
  new_data = iris, 
  outcomes = TRUE
  )

blueprint <- cleaned$blueprint
predictors <- cleaned$predictors
outcomes <- cleaned$outcomes
extras <- cleaned$extras
processed <- blueprint$forge$process(blueprint = blueprint, 
  predictors = predictors, outcomes = outcomes, extras = extras)
#> New names:
#> * Sepal.Length -> Sepal.Length...1
#> * Sepal.Length -> Sepal.Length...6
#> Error: Can't find column `Sepal.Length` in `.data`.

Created on 2019-12-25 by the reprex package (v0.3.0)

DavisVaughan commented 4 years ago

Thanks! Fixed in #121

github-actions[bot] commented 3 years ago

This issue 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.