Package: decompy
decompydecompyis a Python package containing several robust algorithms for matrix decomposition and analysis. The types of algorithms includeRobust PCA or SVD-based methodsMatrix completion methodsRobust matrix or tensor factorization methods.Matrix rank estimation methods.FeaturesData decomposition using various methodsSupport for sparse decomposition, low-rank approximation, and moreUser-friendly API for easy integration into your projectsExtensive documentation and examplesInstallationYou can installdecompyusing pip:pipinstalldecompyUsageHere's a simple example demonstrating how to use decompy for data decomposition:importnumpyasnpfromdecompy.matrix_factorizationimportRobustSVDDensityPowerDivergence# Load your datadata=np.arange(100).reshape(20,5).astype(np.float64)# Perform data decompositionalgo=RobustSVDDensityPowerDivergence(alpha=0.5)result=algo.decompose(data)# Access the decomposed componentsU,V=result.singular_vectors(type="both")S=result.singular_values()low_rank_component=U@S@V.Tsparse_component=data-low_rank_componentprint(low_rank_component)print(sparse_component)While the singular values are about 573 and 7.11 for this case (check theSvariable), it can get highly affected if you use the simple SVD and change a single entry of thedatamatrix.s2 = np.linalg.svd(data, compute_uv = False)
print(np.round(s2, 2))    # estimated by usual SVD
print(np.diag(np.round(S, 2)))    # estimated by robust SVD


data[1, 1] = 10000  # just change a single entry
s3 = np.linalg.svd(data, compute_uv = False)
print(np.round(s3, 2))   # usual SVD shoots up
s4 = algo.decompose(data).singular_values()
print(np.diag(np.round(s4, 2)))You can find more example notebooks in theexamplesfolder. For more detailed usage instructions, please refer to thedocumentation.ContributingContributions are welcome! If you find any issues or have suggestions for improvements, please create an issue or submit a pull request on the GitHub repository. For contributing developers, please refer toCONTRIBUTING.mdfile.LicenseThis project is licensed under theBSD 3-Clause License.List of Algorithms available in thedecompylibraryMatrix Factorization MethodsCurrently, there are20matrix factorization methods available indecompy, as follows:Alternating Direction Method(Yuan and Yang, 2009)-matrix_factorization/adm.pyAugmented Lagrangian Method(Tang and Nehorai)-matrix_factorization/alm.pyAS-RPCA: Active Subspace: Towards Scalable Low-Rank Learning(Liu and Yan, 2012)-matrix_factorization/asrpca.pyDual RPCA(Lin et al. 2009)-matrix_factorization/dual.pyExact Augmented Lagrangian Method(Lin, Chen and Ma, 2010)-matrix_factorization/ealm.pyRobust PCA using Fast PCP Method(Rodriguez and Wohlberg, 2013)-matrix_factorization/fpcp.pyGrassmann Average(Hauberg et al. 2014)website-matrix_factorization/ga.pyTrimmed Grassmann Average(Hauberg et al. 2014)website-matrix_factorization/ga.py(withtrim_percentvalue more than 0)Inexact Augmented Lagrangian Method(Lin et al. 2009)website-matrix_factorization/ialm.pyL1 Filtering(Liu et al. 2011)-matrix_factorization/l1f.pyLinearized ADM with Adaptive Penalty(Lin et al. 2011)-matrix_factorization/ladmap.pyRobust PCA using M-estimation(De la Torre and Black, 2001)website-matrix_factorization/mest.pyMoG-RPCA: Mixture of Gaussians RPCA(Zhao et al. 2014)website-matrix_factorization/mog.pyOutlier PursuitXu et al, 2011-matrix_factorization/op.pyPrincipal Component Pursuit (PCP) Method(Candes et al. 2009)-matrix_factorization/pcp.pyRegL1-ALM: Robust low-rank matrix approximation with missing data and outliers(Zheng et al. 2012)website-matrix_factorization/regl1alm.pyRobust SVD using Density Power Divergence (rSVDdpd) Algorithm(Roy et al, 2023)-matrix_factorization/rsvddpd.pySVT: Singular Value Thresholding(Cai et al. 2008)website-matrix_factorization/svt.pySymmetric Alternating Direction Augmented Lagrangian Method (SADAL)(Goldfarb et al. 2010)-matrix_factorization/sadal.pyRobust PCA using Variational Bayes method(Babacan et al 2012)-matrix_factorization/vbrpca.pyMethods to be added (Coming soon)R2PCP: Riemannian Robust Principal Component Pursuit(Hintermüller and Wu, 2014)DECOLOR: Contiguous Outliers in the Low-Rank Representation(Zhou et al. 2011)website1website2Rank Estimation MethodsInrankmethods/penalized.py-Elbow methodAkaike's Information Criterion (AIC) -https://link.springer.com/chapter/10.1007/978-1-4612-1694-0_15Bayesian Information Criterion (BIC) -https://doi.org/10.1214/aos/1176344136Bai and Ng's Information Criterion for spatiotemporal decomposition (PC1, PC2, PC3, IC1, IC2, IC3) -https://doi.org/10.1111/1468-0262.00273Divergence Information Criterion (DIC) -https://doi.org/10.1080/03610926.2017.1307405Inrankmethods/cvrank.py-Gabriel style Cross validation -http://www.numdam.org/item/JSFS_2002__143_3-4_5_0/Wold style cross validation separate row and column deletion -https://www.jstor.org/stable/1267581Bi-cross validation (Owen and Perry) -https://doi.org/10.1214/08-AOAS227Inrankmethods/bayes.py-Bayesian rank estimation method by Hoffman -https://www.jstor.org/stable/27639896