# Example 1: Standard ChiMerge
set.seed(123)
feature <- rnorm(1000)
# Create a target with a relationship to the feature
target <- rbinom(1000, 1, plogis(2 * feature))
res_cm <- ob_numerical_cm(feature, target,
min_bins = 3,
max_bins = 6,
init_method = "equal_frequency"
)
print(res_cm$bin)
print(res_cm$iv)
# Example 2: Using the Chi2 Algorithm variant
res_chi2 <- ob_numerical_cm(feature, target,
min_bins = 3,
max_bins = 6,
use_chi2_algorithm = TRUE
)
cat("Total IV (ChiMerge):", res_cm$total_iv, "\n")
cat("Total IV (Chi2):", res_chi2$total_iv, "\n")
Run the code above in your browser using DataLab