-
-
Notifications
You must be signed in to change notification settings - Fork 26.9k
ValueError: Buffer dtype mismatch, expected 'double' but got 'float' when calling fit on GradientBoostingRegressor with init = Ridge #10302
Copy link
Copy link
Closed
Description
Description
ValueError: Buffer dtype mismatch, expected 'double' but got 'float' when calling fit on GradientBoostingRegressor with init = Ridge
Steps/Code to Reproduce
from sklearn.ensemble import GradientBoostingRegressor
from sklearn.linear_model import Ridge
base_model_params = {'alpha' : 0.01,
'fit_intercept' :True,
'normalize' : True,
'copy_X' : True,
'max_iter' : None,
'tol' : 0.01,
'solver' : 'sag'}
base_model = Ridge(**base_model_params)
gb_params = {'loss' : 'huber',
'criterion' : 'friedman_mse',
'learning_rate' : 0.05,
'max_depth' : 5,
'max_features' : 'sqrt',
'n_estimators' : 100,
'init' : base_model
}
model = GradientBoostingRegressor(**gb_params)
model.fit(X,Y)Expected Results
The model fits
Actual Results
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
<timed exec> in <module>()
~/anaconda/envs/python3/lib/python3.6/site-packages/sklearn/ensemble/gradient_boosting.py in fit(self, X, y, sample_weight, monitor)
996
997 # fit initial model - FIXME make sample_weight optional
--> 998 self.init_.fit(X, y, sample_weight)
999
1000 # init predictions
~/anaconda/envs/python3/lib/python3.6/site-packages/sklearn/linear_model/ridge.py in fit(self, X, y, sample_weight)
663 self : returns an instance of self.
664 """
--> 665 return super(Ridge, self).fit(X, y, sample_weight=sample_weight)
666
667
~/anaconda/envs/python3/lib/python3.6/site-packages/sklearn/linear_model/ridge.py in fit(self, X, y, sample_weight)
504 max_iter=self.max_iter, tol=self.tol, solver=self.solver,
505 random_state=self.random_state, return_n_iter=True,
--> 506 return_intercept=False)
507 self._set_intercept(X_offset, y_offset, X_scale)
508
~/anaconda/envs/python3/lib/python3.6/site-packages/sklearn/linear_model/ridge.py in ridge_regression(X, y, alpha, sample_weight, solver, max_iter, tol, verbose, random_state, return_n_iter, return_intercept)
425 max_iter, tol, verbose, random_state, False, max_squared_sum,
426 init,
--> 427 is_saga=solver == 'saga')
428 if return_intercept:
429 coef[i] = coef_[:-1]
~/anaconda/envs/python3/lib/python3.6/site-packages/sklearn/linear_model/sag.py in sag_solver(X, y, sample_weight, loss, alpha, beta, max_iter, tol, verbose, random_state, check_input, max_squared_sum, warm_start_mem, is_saga)
295 num_seen_init = 0
296
--> 297 dataset, intercept_decay = make_dataset(X, y, sample_weight, random_state)
298
299 if max_squared_sum is None:
~/anaconda/envs/python3/lib/python3.6/site-packages/sklearn/linear_model/base.py in make_dataset(X, y, sample_weight, random_state)
62 intercept_decay = SPARSE_INTERCEPT_DECAY
63 else:
---> 64 dataset = ArrayDataset(X, y, sample_weight, seed=seed)
65 intercept_decay = 1.0
66
sklearn/utils/seq_dataset.pyx in sklearn.utils.seq_dataset.ArrayDataset.__cinit__()
ValueError: Buffer dtype mismatch, expected 'double' but got 'float'
Versions
Darwin-15.0.0-x86_64-i386-64bit
Python 3.6.2 |Continuum Analytics, Inc.| (default, Jul 20 2017, 13:14:59)
[GCC 4.2.1 Compatible Apple LLVM 6.0 (clang-600.0.57)]
NumPy 1.12.1
SciPy 0.19.1
Scikit-Learn 0.19.0
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels