Summary
The convert_data.R file references contr_one_hot in local_one_hot_contrasts() (line 142), but this function is not defined in tidyclust. This means the indicators = "one_hot" code path in .convert_form_to_x_fit() and .convert_form_to_x_new() is currently broken.
Current behavior
data <- data.frame(x = 1:10, cat = factor(rep(c("a", "b"), 5)))
.convert_form_to_x_fit(~., data, indicators = "one_hot")
#> Error: object 'contr_one_hot' of mode 'function' was not found
Options
-
Import from hardhat: The contr_one_hot function exists in the hardhat package. We could import it.
-
Define locally: Copy/adapt the function into tidyclust.
-
Remove the code path: If no engine uses indicators = "one_hot", consider removing this dead code.
Context
- Currently no engine in tidyclust uses
predictor_indicators = "one_hot" encoding
- Tests for one-hot paths are currently skipped
- This was discovered during test coverage improvements
Related code
# R/convert_data.R lines 140-145
local_one_hot_contrasts <- function(frame = rlang::caller_env()) {
contrasts <- getOption("contrasts")
contrasts["unordered"] <- "contr_one_hot" # <- function doesn't exist
rlang::local_options(contrasts = contrasts, .frame = frame)
}
Summary
The
convert_data.Rfile referencescontr_one_hotinlocal_one_hot_contrasts()(line 142), but this function is not defined in tidyclust. This means theindicators = "one_hot"code path in.convert_form_to_x_fit()and.convert_form_to_x_new()is currently broken.Current behavior
Options
Import from hardhat: The
contr_one_hotfunction exists in the hardhat package. We could import it.Define locally: Copy/adapt the function into tidyclust.
Remove the code path: If no engine uses
indicators = "one_hot", consider removing this dead code.Context
predictor_indicators = "one_hot"encodingRelated code