Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion R/R/ebm.R
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ ebm_classify <- function(
rng
)
for(i_feature in 1:n_features) {
term_scores[[col_names[i_feature]]] <- result_list$model_update[[i_feature]]
if(1 == i_outer_bag) {
term_scores[[col_names[i_feature]]] <- result_list$model_update[[i_feature]]
} else {
term_scores[[col_names[i_feature]]] <- term_scores[[col_names[i_feature]]] + result_list$model_update[[i_feature]]
}
}
}
for(col_name in col_names) {
Expand Down
9 changes: 9 additions & 0 deletions R/build.R
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,15 @@ for (file in list.files(file.path(root_path, "R"))) {
file.copy(from = file.path(root_path, "R", file), to = file.path(dest_path, "R", file))
}

# tests directory
tests_path <- file.path(root_path, "tests")
if(dir.exists(tests_path)) {
dir.create(file.path(dest_path, "tests"))
for (file in list.files(tests_path)) {
file.copy(from = file.path(tests_path, file), to = file.path(dest_path, "tests", file))
}
}

# src directory (R C++ files)
dir.create(file.path(dest_path, "src"))
file.copy(from = file.path(root_path, "src", "interpret_R.cpp"), to = file.path(dest_path, "src", "interpret_R.cpp"))
Expand Down
29 changes: 29 additions & 0 deletions R/tests/outer_bag_aggregation.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
# Copyright (c) 2026 The InterpretML Contributors
#
# Licensed under the MIT license.

library(interpret)

X <- data.frame(x = seq_len(100))
y <- c(rep(0, 90), rep(1, 10))

model <- ebm_classify(
X,
y,
outer_bags = 16,
random_state = 42
)

probabilities <- ebm_predict_proba(model, X)
difference <- abs(mean(probabilities) - mean(y))

if(0.02 <= difference) {
stop(
sprintf(
"Expected mean probability near %.9f, got %.9f",
mean(y),
mean(probabilities)
),
call. = FALSE
)
}
Loading