Skip to content

Commit e555c01

Browse files
committedNov 6, 2024
add uniform feature subsampling to gam_shap
1 parent d47ead5 commit e555c01

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed
 

‎imodels/algebraic/gam_shap.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,13 @@ def fit(self, X, y):
3030

3131
for _ in range(self.n_estimators):
3232
# Randomly select a subset of features
33+
if isinstance(self.feature_fraction, float):
34+
n_features = max(1, int(self.feature_fraction * n_features))
35+
elif self.feature_fraction == 'uniform':
36+
n_features = rng.integers(1, n_features + 1)
3337
feature_subset = rng.choice(
3438
n_features,
35-
size=int(self.feature_fraction * n_features),
39+
size=n_features,
3640
replace=False
3741
)
3842
self.feature_subsets.append(feature_subset)

0 commit comments

Comments
 (0)