# \donttest{
# Numerical feature with outliers
set.seed(123)
feature_num <- c(rnorm(95, 50, 10), NA, NA, 200, -100, 250)
target <- sample(0:1, 100, replace = TRUE)
# Preprocess with IQR outlier detection
result_iqr <- ob_preprocess(
feature = feature_num,
target = target,
outlier_process = TRUE,
outlier_method = "iqr",
iqr_k = 1.5
)
print(result_iqr$report)
# Shows: missing_count = 2, outlier_count = 3
# Categorical feature
feature_cat <- c(rep("A", 30), rep("B", 40), rep("C", 28), NA, NA)
target_cat <- sample(0:1, 100, replace = TRUE)
result_cat <- ob_preprocess(
feature = feature_cat,
target = target_cat,
char_miss_value = "Missing"
)
# Compare original vs preprocessed
head(result_cat$preprocess)
# Shows NA replaced with "Missing"
# Return only report (no data)
result_report <- ob_preprocess(
feature = feature_num,
target = target,
preprocess = "report",
outlier_process = TRUE
)
# Grubbs' test (most conservative)
result_grubbs <- ob_preprocess(
feature = feature_num,
target = target,
outlier_process = TRUE,
outlier_method = "grubbs",
grubbs_alpha = 0.01 # Very strict
)
# }
Run the code above in your browser using DataLab