Skip to content

fix: make col_sample min equals to 1 #385

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 4, 2025
Merged
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 ngboost/ngboost.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class NGBoost:
n_estimators : the number of boosting iterations to fit
learning_rate : the learning rate
minibatch_frac : the percent subsample of rows to use in each boosting iteration
col_sample : the percent subsample of columns to use in each boosting iteration
verbose : flag indicating whether output should be printed during fitting
verbose_eval : increment (in boosting iterations) at which output should be printed
tol : numerical tolerance to be used in optimization
Expand Down Expand Up @@ -147,7 +148,10 @@ def sample(self, X, Y, sample_weight, params):
)

if self.col_sample != 1.0:
col_size = int(self.col_sample * X.shape[1])
if self.col_sample > 0.0:
col_size = max(1, int(self.col_sample * X.shape[1]))
else:
col_size = 0
col_idx = self.random_state.choice(
np.arange(X.shape[1]), col_size, replace=False
)
Expand Down