8000 [MRG+1] Convert y in GradientBoosting to float64 instead of float32 by adrinjalali · Pull Request #13524 · scikit-learn/scikit-learn · GitHub
[go: up one dir, main page]

Skip to content

[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 6 commits into from
Apr 9, 2019
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
10 changes: 7 additions & 3 deletions sklearn/ensemble/gradient_boosting.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member

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 and Y_DTYPE.

Copy link
Member Author

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? ;)

from ..tree._tree import TREE_LEAF
from . import _gb_losses

Expand Down Expand Up @@ -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)
Copy link
Member

Choose a reason for hiding this comment

The 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
Expand All @@ -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:
Expand Down Expand Up @@ -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

Expand Down
0