Skip to content

Commit 3d3b10b

Browse files
committed
Relax restriction on max_interaction (at least for now)
1 parent 1159ea4 commit 3d3b10b

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

R/rpf.R

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -103,16 +103,20 @@ rpf_bridge <- function(processed, max_interaction = 1, ntrees = 50, splits = 30,
103103
hardhat::validate_outcomes_are_univariate(processed$outcomes)
104104
predictors <- preprocess_predictors_fit(processed)
105105
outcomes <- preprocess_outcome(processed, loss)
106+
p <- ncol(predictors$predictors_matrix)
106107

107108
# Check arguments
108-
checkmate::assert_int(
109-
max_interaction,
110-
lower = 0, upper = ncol(predictors$predictors_matrix)
111-
)
109+
checkmate::assert_int(max_interaction, lower = 0)
112110

113-
# rewrite max_interaction so 0 -> "maximum", e.g. ncol(x):
111+
# rewrite max_interaction so 0 -> "maximum", e.g. ncol(X)
114112
if (max_interaction == 0) {
115-
max_interaction <- ncol(predictors$predictors_matrix)
113+
max_interaction <- p
114+
}
115+
# same applies to values > p
116+
if (max_interaction > p) {
117+
message("`max_interaction` set to ", max_interaction, " but ncol(X) is ", p, ".\n",
118+
"Setting `max_interaction` to ", p)
119+
max_interaction <- p
116120
}
117121

118122
checkmate::assert_int(ntrees, lower = 1)

0 commit comments

Comments
 (0)