Skip to content

Commit

Permalink
Fix two levels binary features (in case one of values not occuring)
Browse files Browse the repository at this point in the history
  • Loading branch information
AniekMarkus committed Aug 2, 2024
1 parent 39ca501 commit 7a8a60f
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion R/HelperFunctions.R
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ saveData <- function(output_path, train_data, file_name) {

# Fix col type for binary data
binary_cols <- sapply(1:ncol(train_data), function(c) all(train_data[[c]] %in% 0:1))
train_data[binary_cols] <- lapply(colnames(train_data[binary_cols]), function(c) factor(train_data[[c]], labels=c(0,1)))
train_data[binary_cols] <- lapply(colnames(train_data[binary_cols]), function(c) factor(train_data[[c]], levels=c("0","1"), labels=c(0,1)))

# Order data (first binary then continuous features)
train_data <- cbind(train_data[binary_cols],train_data[!binary_cols]) # Order needed for correct functioning of main algorithm in C++
Expand Down

0 comments on commit 7a8a60f

Please sign in to comment.