Skip to content

Commit 25bc190

Browse files
committed
Add target_col
1 parent 58ecc64 commit 25bc190

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

R/machine_learning.R

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -297,10 +297,10 @@ compute_k_fold_CV = function(model, k_folds, n_rep, stacking = FALSE, metric = "
297297

298298
if(is.null(fold_construction_fun)){ ### Preprocessing (remove collinear variables and low variance)
299299
if(LODO == TRUE){
300-
train_data = preprocess_features(model %>% dplyr::select(-dataset), cor_thresh = 0.9) %>%
300+
train_data = preprocess_features(model %>% dplyr::select(-dataset), cor_thresh = 0.9, target_col = "target") %>%
301301
dplyr::mutate(dataset = model$dataset)
302302
}else{
303-
train_data = preprocess_features(model, cor_thresh = 0.9)
303+
train_data = preprocess_features(model, cor_thresh = 0.9, target_col = "target")
304304
}
305305
}else{
306306
train_data = model
@@ -440,7 +440,7 @@ compute_k_fold_CV = function(model, k_folds, n_rep, stacking = FALSE, metric = "
440440
test_data_i <- result[[parameter_i]][["test_data"]]
441441

442442
# Preprocessing features (remove collinear variables and no-variance)
443-
train_data_i <- preprocess_features(train_data_i, cor_thresh = 0.9)
443+
train_data_i <- preprocess_features(train_data_i, cor_thresh = 0.9, target_col = "target")
444444

445445
# Replace in original train/test datasets
446446
result[[parameter_i]][["train_data"]] <- train_data_i
@@ -473,7 +473,7 @@ compute_k_fold_CV = function(model, k_folds, n_rep, stacking = FALSE, metric = "
473473
test_data_i <- result[["test_data"]]
474474

475475
# Preprocessing
476-
train_data_i <- preprocess_features(train_data_i, cor_thresh = 0.9)
476+
train_data_i <- preprocess_features(train_data_i, cor_thresh = 0.9, target_col = "target")
477477

478478
# Replace
479479
result[["train_data"]] = train_data_i
@@ -600,7 +600,7 @@ compute_k_fold_CV = function(model, k_folds, n_rep, stacking = FALSE, metric = "
600600
)
601601

602602
# Preprocess features
603-
training_set <- preprocess_features(training_all[[1]], cor_thresh = 0.9)
603+
training_set <- preprocess_features(training_all[[1]], cor_thresh = 0.9, target_col = "target")
604604

605605
# Retrieve custom_output
606606
custom_output <- training_all[[2]]
@@ -3521,7 +3521,7 @@ wrapper_train_best_hyperparams_classification <- function(train_data, optimized,
35213521
c(list(data = train_data, bestune = optimized$Besttune), fold_construction_args_fixed))
35223522

35233523
# Preprocess features
3524-
training_set <- preprocess_features(training_all[[1]], cor_thresh = 0.9)
3524+
training_set <- preprocess_features(training_all[[1]], cor_thresh = 0.9, target_col = "target")
35253525

35263526
# Wrap correct model type for lasso and ridge
35273527
if(ml_method == "lasso"){

0 commit comments

Comments
 (0)