【问题标题】:Randomized SVD for LSA\LSI on Windows environmentWindows 环境下 LSA\LSI 的随机 SVD
【发布时间】:2013-06-05 03:28:33
【问题描述】:

我正在开展一个项目,其中包括使用潜在语义分析 (LSA)。 这需要使用奇异值分解 (SVD),有时用于大型数据集。 是否有可用于 Windows\Visual Studio 环境的随机 SVD (rSVD) 实现?我看到了一个名为 redsvd 的项目,但它似乎只在 Linux 上受支持。

【问题讨论】:

    标签: c# svd lsa


    【解决方案1】:

    ILNumerics 可能有它,但我没有看到他们是否执行 rSVD,而且我没有使用该库的个人经验,但幸运的是它可以通过 NuGet 获得。

    http://ilnumerics.net

    这里是关于他们的 SVD 实现的文档:

    http://ilnumerics.net/apidoc/Index.html?topic=html/Overload_ILNumerics_ILMath_svd.htm

    还有 NAG,但它是付费的:http://www.nag.co.uk/numeric/numerical_libraries.asp

    我还检查了 redsvd,我敢打赌我可以为你将它移植到 C#,或者至少让它在 Windows 上编译。如果这些不能满足您的需求,请告诉我,我会看看端口的复杂性。

    更新:

    今晚回到家,决定试一试。这是使用 Visual Studio 2010 在 Windows 上运行 redsvd 的一种非常快速的方法。我将其发布在 github 上:

    https://github.com/hoonto/redsvdwin

    在 Visual Studio 中打开 rsvd3.sln,构建它,您将在 Debug 目录中获得一个 rsvd3.exe。

    运行:

    C:\Users\MLM\Documents\Visual Studio 2010\Projects\redsvdwin\Debug>rsvd3.exe
    usage: redsvd --input=string --output=string [options] ...
    
    redsvd supports the following format types (one line for each row)
    
    [format=dense] (<value>+\n)+
    [format=sparse] ((colum_id:value)+\n)+
    Example:
    >redsvd -i imat -o omat -r 10 -f dense
    compuate SVD for a dense matrix in imat and output omat.U omat.V, and omat.S
    with the 10 largest eigen values/vectors
    >redsvd -i imat -o omat -r 3 -f sparse -m PCA
    compuate PCA for a sparse matrix in imat and output omat.PC omat.SCORE
    with the 3 largest principal components
    
    options:
      -i, --input     input file (string)
      -o, --output    output file's prefix (string)
      -r, --rank      rank       (int [=10])
      -f, --format    format type (dense|sparse) See example.  (string [=dense])
      -m, --method    method (SVD|PCA|SymEigen) (string [=SVD])
    

    它就在那里。顺便说一句,这会构建 redsvdMain.cpp,如果您想要带有 main 的 Incr 文件,请排除 redsvdMain.cpp 并包含 redsvdMainIncr.cpp。由于两者都有 main,我只是排除了 Incr 版本并构建了常规版本。

    另外,我也在 github 存储库中包含了 Eigen3 标头,并将它们放在附加包含中以进行解决方案配置,因此您根本不需要摆弄它。

    最后一件事,据我所知,对于 Visual Studio,没有 cxxabi.h 这样的东西,所以我做了一些作弊,你会看到我在哪里进行了更改,因为它们会被这样评论:

    //MLM: commented next 3
    //...
    //...
    //...
    //MLM: added 1
    ...
    

    等等。因此,如果您需要进行调整,您会知道我的更改在哪里。

    【讨论】:

    • 首先,感谢您的努力!其次,SVD 的有效实现不能用 Ilnumerics 执行,因为没有经济 QR 分解的实现......
    • 很高兴,如果您对此有任何问题,请随时通过 SO 或通过 github 联系。对 Ilnumerics 和经济 QR 感兴趣。这些天我的数学很生疏,但我想知道为什么 Ilnumerics 会竭尽全力而不这样做?根据 Matlab,它只是:“如果 m > n,则只计算 Q 的前 n 列和 R 的前 n 行。如果 m
    【解决方案2】:

    ILNumerics 中的 qr 有一个重载 ILMath.qr(A, outR, outE,economic) 允许执行经济规模的分解。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-05-12
      • 1970-01-01
      • 2011-12-10
      • 2015-07-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-02-15
      相关资源
      最近更新 更多