-
-
Notifications
You must be signed in to change notification settings - Fork 26.1k
Closed
Labels
Description
Describe the bug
A validation check for the precomputed gram matrix has been introduced in version 1.0.0 (#19004).
This check sometimes misleadingly fails when the matrix has dtype float32 and the arbitrary selected feature columns are sparse.
Code snippet to reproduce attached.
I could add a pr in the following days to fix that if wanted.
Steps/Code to Reproduce
from sklearn.linear_model import LassoCV
import numpy as np
m = LassoCV()
np.random.seed(seed=3)
X = np.random.random((10000, 50)).astype(np.float32)
X[:, 25] = np.where(X[:, 25] < 0.98, 0, 1)
X[:, 26] = np.where(X[:, 26] < 0.98, 0, 1)
y = np.random.random((10000, 1)).astype(np.float32)
m.fit(X, y)
Expected Results
No Exception thrown
Actual Results
ValueError: Gram matrix passed in via 'precompute' parameter did not pass validation when a single element was checked - please check that it was computed properly. For element (25,26) we computed -0.4163646101951599 but the user-supplied value was -0.41635191440582275.
Versions
1.0.1