【发布时间】:2016-07-19 03:53:42
【问题描述】:
这是我在执行此操作时遇到的 scikit-learn 错误
my_estimator = LassoLarsCV(fit_intercept=False, normalize=False, positive=True, max_n_alphas=1e5)
请注意,如果我将 max_n_alphas 从 1e5 降低到 1e4,则不会再出现此错误。
有人知道发生了什么吗?
当我调用时发生错误
my_estimator.fit(x, y)
我在40 维度中有40k 数据点。
完整的堆栈跟踪如下所示
File "/usr/lib64/python2.7/site-packages/sklearn/linear_model/least_angle.py", line 1113, in fit
axis=0)(all_alphas)
File "/usr/lib64/python2.7/site-packages/scipy/interpolate/polyint.py", line 79, in __call__
y = self._evaluate(x)
File "/usr/lib64/python2.7/site-packages/scipy/interpolate/interpolate.py", line 498, in _evaluate
out_of_bounds = self._check_bounds(x_new)
File "/usr/lib64/python2.7/site-packages/scipy/interpolate/interpolate.py", line 525, in _check_bounds
raise ValueError("A value in x_new is below the interpolation "
ValueError: A value in x_new is below the interpolation range.
【问题讨论】:
-
当我运行
from sklearn.linear_model import LassoLarsCV后跟您的代码行时,我没有收到任何错误。请提供足够的代码来重现您遇到的错误以及完整的回溯消息。 -
该行没有发生错误,但是当我调用 .fit() 时。不幸的是,这里很难重现,我的数据集有 40k 点。
-
scipy 中的插值器通常要求
x值单调递增。x是否为您的数据集单调增加?如果不是,请尝试使用x作为键对数据集进行排序,然后重试。如果可行,请告诉我,我会为赏金添加正确的答案:) -
如果没有赏金,我会投票关闭,因为缺少minimal reproducible example。
-
好吧 - 为“荒谬的建议”道歉,但您会注意到实际上引发错误的位是
scipy包中的interpolate.py,它确实有这些要求。但是,如果您不提供数据进行复制并认为建议提供免费帮助的人很荒谬是个好主意,我真的不介意进一步跟踪它。
标签: python scikit-learn regression lars