Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 0372ba7

Browse files
author
Fabian Pedregosa
committed
FIX: explicit conversion to float64 in ElasticNet
as_float_array is not enough because cd_fast does not accept float32.
1 parent f4eced3 commit 0372ba7

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

sklearn/linear_model/coordinate_descent.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -119,16 +119,15 @@ def fit(self, X, y, Xy=None, coef_init=None):
119119
To avoid memory re-allocation it is advised to allocate the
120120
initial data in memory directly using that format.
121121
"""
122-
X = as_float_array(X, self.copy_X)
122+
# X and y must be of type float64
123+
X = np.asanyarray(X, dtype=np.float64)
123124
y = np.asarray(y, dtype=np.float64)
124125

125126
n_samples, n_features = X.shape
126127

127128
X_init = X
128129
X, y, X_mean, y_mean, X_std = self._center_data(X, y,
129-
self.fit_intercept,
130-
self.normalize,
131-
copy=False)
130+
self.fit_intercept, self.normalize, copy=self.copy_X)
132131
precompute = self.precompute
133132
if X_init is not X and hasattr(precompute, '__array__'):
134133
precompute = 'auto' # recompute Gram

0 commit comments

Comments
 (0)