linfa icon indicating copy to clipboard operation
linfa copied to clipboard

Implement PCA for f32 and f64

Open YuhanLiin opened this issue 3 years ago • 4 comments

Addresses #232

Adds PCA impl for f32 for all BLAS backends using macros. Does not involve the Float trait.

There is currently a logic bug, as the test_explained_variance_diag and test_whitening_small tests are currently failing on f32. It might be related to the TruncateSvd code. @bytesnake any ideas?

YuhanLiin avatar Aug 07 '22 04:08 YuhanLiin

I also ran the tests with BLAS backend and white_small passes, but explained_variance_diag still fails.

YuhanLiin avatar Aug 07 '22 16:08 YuhanLiin

for explained_variance_diag this relates to https://github.com/rust-ml/linfa-linalg/pull/11 when decreasing to single-precision floats we can't extract as many eigenvalues without losing coherence

bytesnake avatar Aug 07 '22 18:08 bytesnake

the same occurs for test_whitening_small, it calculate covariance of 2x2 https://github.com/rust-ml/linfa-linalg/blob/main/src/lobpcg/svd.rs#L200

bytesnake avatar Aug 07 '22 18:08 bytesnake

I propose first fixing first https://github.com/rust-ml/linfa-linalg/pull/11 by adding the 1/5 rules to TruncatedSvd and TruncatedEig and then test again

bytesnake avatar Aug 07 '22 18:08 bytesnake