44
44
from time import time
45
45
from ..model_selection import train_test_split
46
46
from ..tree .tree import DecisionTreeRegressor
47
- from ..tree ._tree import DTYPE
47
+ from ..tree ._tree import DTYPE , DOUBLE
48
48
from ..tree ._tree import TREE_LEAF
49
49
from . import _gb_losses
50
50
@@ -1432,7 +1432,9 @@ def fit(self, X, y, sample_weight=None, monitor=None):
1432
1432
self ._clear_state ()
1433
1433
1434
1434
# Check input
1435
- X , y = check_X_y (X , y , accept_sparse = ['csr' , 'csc' , 'coo' ], dtype = DTYPE )
1435
+ # Since check_array converts both X and y to the same dtype, but the
1436
+ # trees use different types for X and y, checking them separately.
1437
+ X = check_array (X , accept_sparse = ['csr' , 'csc' , 'coo' ], dtype = DTYPE )
1436
1438
n_samples , self .n_features_ = X .shape
1437
1439
1438
1440
sample_weight_is_none = sample_weight is None
@@ -1444,6 +1446,8 @@ def fit(self, X, y, sample_weight=None, monitor=None):
1444
1446
1445
1447
check_consistent_length (X , y , sample_weight )
1446
1448
1449
+ y = check_array (y , accept_sparse = 'csc' , ensure_2d = False , dtype = None )
1450
+ y = column_or_1d (y , warn = True )
1447
1451
y = self ._validate_y (y , sample_weight )
1448
1452
1449
1453
if self .n_iter_no_change is not None :
@@ -1722,7 +1726,7 @@ def _validate_y(self, y, sample_weight):
1722
1726
# consistency with similar method _validate_y of GBC
1723
1727
self .n_classes_ = 1
1724
1728
if y .dtype .kind == 'O' :
1725
- y = y .astype (np . float64 )
1729
+ y = y .astype (DOUBLE )
1726
1730
# Default implementation
1727
1731
return y
1728
1732
0 commit comments