# \donttest{
# Mock data
train_data <- data.frame(
income = c(50000, 75000, 30000, 45000, 80000, 60000),
default = c(0, 0, 1, 1, 0, 0)
)
test_data <- data.frame(
income = c(55000, 35000, 90000)
)
# Train binning on training set
train_bins <- ob_numerical_mdlp(
feature = train_data$income,
target = train_data$default
)
# Apply to test set
test_woe <- ob_apply_woe_num(
obresults = train_bins,
feature = test_data$income
)
# Handle custom missing indicators (e.g., -999, -1)
test_woe <- ob_apply_woe_num(
obresults = train_bins,
feature = test_data$income,
missing_values = c(-999, -1, -9999)
)
# Use left-closed intervals (match scikit-learn convention)
test_woe <- ob_apply_woe_num(
obresults = train_bins,
feature = test_data$income,
include_upper_bound = FALSE
)
# }
Run the code above in your browser using DataLab