-
-
Notifications
You must be signed in to change notification settings - Fork 25.9k
[MRG+1] Convert y in GradientBoosting to float64 instead of float32 #13524
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
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
acbe1f6
fix y validation
adrinjalali 1b14b89
Merge remote-tracking branch 'upstream/master' into gbc/float32
adrinjalali 9fa4b30
fix y validation
adrinjalali 97304d9
fix the validation again
adrinjalali f95d6b1
Merge remote-tracking branch 'upstream/master' into gbc/float32
adrinjalali c6dfc8b
add comment
adrinjalali File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,7 +44,7 @@ | |
from time import time | ||
from ..model_selection import train_test_split | ||
from ..tree.tree import DecisionTreeRegressor | ||
from ..tree._tree import DTYPE | ||
from ..tree._tree import DTYPE, DOUBLE | ||
from ..tree._tree import TREE_LEAF | ||
from . import _gb_losses | ||
|
||
|
@@ -1432,7 +1432,9 @@ def fit(self, X, y, sample_weight=None, monitor=None): | |
self._clear_state() | ||
|
||
# Check input | ||
X, y = check_X_y(X, y, accept_sparse=['csr', 'csc', 'coo'], dtype=DTYPE) | ||
# Since check_array converts both X and y to the same dtype, but the | ||
# trees use different types for X and y, checking them separately. | ||
X = check_array(X, accept_sparse=['csr', 'csc', 'coo'], dtype=DTYPE) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's worth commenting why check_X_y is not used. |
||
n_samples, self.n_features_ = X.shape | ||
|
||
sample_weight_is_none = sample_weight is None | ||
|
@@ -1444,6 +1446,8 @@ def fit(self, X, y, sample_weight=None, monitor=None): | |
|
||
check_consistent_length(X, y, sample_weight) | ||
|
||
y = check_array(y, accept_sparse='csc', ensure_2d=False, dtype=None) | ||
y = column_or_1d(y, warn=True) | ||
y = self._validate_y(y, sample_weight) | ||
|
||
if self.n_iter_no_change is not None: | ||
|
@@ -1715,7 +1719,7 @@ def _validate_y(self, y, sample_weight): | |
# consistency with similar method _validate_y of GBC | ||
self.n_classes_ = 1 | ||
if y.dtype.kind == 'O': | ||
y = y.astype(np.float64) | ||
y = y.astype(DOUBLE) | ||
# Default implementation | ||
return y | ||
|
||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is interesting how this is our naming convention for the dtypes of X and y. In the future we may consider
X_DTYPE
andY_DTYPE
.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah I know. You're the second +1 here now @thomasjpfan, wanna push the green button? ;)