Skip to content

Commit

Permalink
add uniform feature subsampling to gam_shap
Browse files Browse the repository at this point in the history
  • Loading branch information
csinva committed Nov 6, 2024
1 parent d47ead5 commit e555c01
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion imodels/algebraic/gam_shap.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,13 @@ def fit(self, X, y):

for _ in range(self.n_estimators):
# Randomly select a subset of features
if isinstance(self.feature_fraction, float):
n_features = max(1, int(self.feature_fraction * n_features))
elif self.feature_fraction == 'uniform':
n_features = rng.integers(1, n_features + 1)
feature_subset = rng.choice(
n_features,
size=int(self.feature_fraction * n_features),
size=n_features,
replace=False
)
self.feature_subsets.append(feature_subset)
Expand Down

0 comments on commit e555c01

Please sign in to comment.