Skip to content

ENH Uses binned values from training to find missing values #16883

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
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
7 changes: 5 additions & 2 deletions sklearn/ensemble/_hist_gradient_boosting/gradient_boosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,6 @@ def fit(self, X, y, sample_weight=None):
X_train, y_train, sample_weight_train = X, y, sample_weight
X_val = y_val = sample_weight_val = None

has_missing_values = np.isnan(X_train).any(axis=0).astype(np.uint8)

# Bin the data
# For ease of use of the API, the user-facing GBDT classes accept the
# parameter max_bins, which doesn't take into account the bin for
Expand All @@ -203,6 +201,11 @@ def fit(self, X, y, sample_weight=None):
else:
X_binned_val = None

# Uses binned data to check for missing values
has_missing_values = (
X_binned_train == self.bin_mapper_.missing_values_bin_idx_).any(
axis=0).astype(np.uint8)

if self.verbose:
print("Fitting gradient boosted rounds:")

Expand Down