Skip to content

Commit

Permalink
add cat_penalty develop parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbkoch committed Jan 3, 2025
1 parent e3aa1b2 commit ccd5db5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions python/interpret-core/interpret/develop.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
"cat_smooth": math.inf, # math.inf means use only the gradient for sorting
"max_cat_threshold": 9223372036854775807,
"cat_include": 0.75,
"cat_penalty": 0.0,
"purify_boosting": False,
"purify_result": False,
"randomize_initial_feature_order": True,
Expand Down
5 changes: 5 additions & 0 deletions python/interpret-core/interpret/glassbox/_ebm/_boost.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,11 @@ def boost(
max_leaves=max_leaves,
monotone_constraints=term_monotone,
)

if contains_nominals and len(term_features[term_idx]) == 1:
# penalize nominals a bit because they benefit from sorting categories
avg_gain *= 1.0 - develop.get_option("cat_penalty")

gainkey = (-avg_gain, native.generate_seed(rng), term_idx)
if not make_progress:
if bestkey is None or gainkey < bestkey:
Expand Down

0 comments on commit ccd5db5

Please sign in to comment.