今天为了安装某个包给scikit-learn升级了,从0.23.1升级到1.0.2然后发现LassoCV跑不动了。
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)
报错如下:
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.
说是新版scikit-learn增加了一个验证Gram matrix的步骤
在下面的网址中翻了翻,没看明白........
https://github.com/scikit-learn/scikit-learn/issues/21997
但是看懂了一句话:
然后把输入数据都改成float64就没事了