I am running a regression with a sparse rank-deficient matrix where many columns are correlated with others. At the moment, I remove all columns with a correlation over 0.8. The matrix has 12k columns and 35k observations, and I drop about 2k columns.
For example, my text may mention cities and I have three highly correlated n-grams: "New York", "York City", and "New York City". At the moment, I am dropping all three of them and I lose one dimension in the rank of the matrix. I am looking for a package that keeps makes the matrix invertible and keeps its rank as high as possible; and whose transformation on that matrix can be applied to a single row, because I want to predict the values when a single new observation arrives.
I found the PyPi package collinearity
. Converting the sparse matrix to a dense matrix is fast, but the collinearity package on it is prohibitively slow (several hours). This is probably because, from reading the description, it adds features one at a time and recomputes all correlations.
This thread links to a paper with a QR-Column Pivoting algorithm to select the most linearly independent columns. Since Singular Value Decompositions and matrix operations are optimized for sparse matrices, does a package exist that already does this conversion of a rank-deficient sparse matrix to a full-rank, invertible matrix?