Skip to content

Commit

Permalink
fix: correct factor collapsing for ordered factors
Browse files Browse the repository at this point in the history
  • Loading branch information
advieser committed Nov 5, 2024
1 parent 4b311b6 commit 2e17881
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
4 changes: 2 additions & 2 deletions R/PipeOpCollapseFactors.R
Original file line number Diff line number Diff line change
Expand Up @@ -114,9 +114,9 @@ PipeOpCollapseFactors = R6Class("PipeOpCollapseFactors",
if (position == 1) {
cmap[[2]] = c(cmap[[2]], eliminating)
} else if (position == length(cmap) || dtable[position - 1] < dtable[position + 1]) {
cmap[[position - 1]] = c(cmap[[position - 1]], eliminating)
cmap[[position - 1]] = c(cmap[[position - 1]], cmap[[eliminating]])
} else {
cmap[[position + 1]] = c(cmap[[position + 1]], eliminating)
cmap[[position + 1]] = c(cmap[[position + 1]], cmap[[eliminating]])
}
dtable = dtable[-position]
cmap[[position]] = NULL
Expand Down
1 change: 1 addition & 0 deletions tests/testthat/test_pipeop_collapsefactors.R
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ test_that("PipeOpCollapseFactors", {
# correct levels are chosen for this
train_out = op$train(list(task))[[1]]

# test: ordered, correct renaming

# test: prevalance works
# test: absolute works
Expand Down

0 comments on commit 2e17881

Please sign in to comment.