12

我正在尝试使用 scikit-learn 中包含的广义线性模型拟合方法来拟合向量自回归 (VAR) 模型。线性模型的形式为y = X w,但系统矩阵X具有非常奇特的结构:它是块对角线,并且所有块都是相同的。为了优化性能和内存消耗,模型可以表示为Y = BW,其中B是来自X的块,并且YW现在是矩阵而不是向量。LinearRegression、Ridge、RidgeCV、Lasso 和 ElasticNet 类很容易接受后一种模型结构。但是,由于 Y 是二维的,拟合 LassoCV 或 ElasticNetCV 会失败。

我发现https://github.com/scikit-learn/scikit-learn/issues/2402 从这个讨论中我假设 LassoCV/ElasticNetCV 的行为是有意的。除了手动实施交叉验证之外,还有其他方法可以优化 alpha/rho 参数吗?

此外,scikit-learn 中的贝叶斯回归技术也期望y是一维的。有没有办法解决?

注意:我使用 scikit-learn 0.14(稳定)

4

2 回答 2

3

How crucial is the performance and memory optimization gained by using this formulation of the regression? Given that your reformulation breaks scikit-learn, I wouldn't really call it an optimization... I would suggest:

  1. Running the unoptimized version and waiting (if possible).

  2. Git pull the following code, which supposedly solves your problem. It's referenced in the conversation you posted from the scikit-learn github project. See here for instructions on building scikit-learn from a git pull. You can then add the branched scikit-learn location to your python path and execute your regression using the modified library code. Be sure to post your experiences and any issues you encounter; I'm sure the scikit developers would appreciate it.

于 2013-12-29T01:45:21.267 回答
2

要预测矩阵而不是向量,有 Lasso 和 ElasticNet 对应的 MultiTask*:

http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.MultiTaskLasso.html http://scikit-learn.org/stable/modules/generated/sklearn.linear_model.MultiTaskElasticNet.html

于 2014-11-14T10:07:47.477 回答