mlxtend icon indicating copy to clipboard operation
mlxtend copied to clipboard

Use SciPy SVD instead of NumPy SVD.

Open rasbt opened this issue 1 year ago • 1 comments

As noted here NumPy's SVD can occasionally be incorrect, and it is better to use scipy.linalg.svd(cov, lapack_driver='gesvd') instead.

SVD is used in the PCA class here: https://github.com/rasbt/mlxtend/blob/master/mlxtend/feature_extraction/principal_component_analysis.py

rasbt avatar Jan 14 '24 00:01 rasbt

There are potential performance benefits as well. From scipy's documentation:

... advantage of using scipy.linalg over numpy.linalg is that it is always compiled with BLAS/LAPACK support, while for NumPy this is optional. Therefore, the SciPy version might be faster depending on how NumPy was installed.

So the class could also benefit from using the scipy's eigendecomposition.

fkdosilovic avatar Jan 19 '24 22:01 fkdosilovic