leverage_score

spalor.matrix_tools.leverage_score.leverage_score(A, k=10, method='exact', axis=0)[source]

Calcluates the leverage statistic for each row (or column) of X when calculating the rank k approximation of A.

A: either a n by d np-array or a tuple containing the SVD of A (the output of np.linalg.svd or the output of scipy.sparse.linalg.svds) k: rank for which the leverage statitics of the low rank approximation are calculated for method: If exact, calculate leverage scores using the rank-k svd [1]. if approximate, use the Fast Johnson-Lindenstrauss Transform to approximate leverage scores[2]. axis: dimension of the matrix to calclute leverage scores for (0: calculate score for columns, 1: calculate for rows)

l: vector of leverage scores with length A.shape[axis]

[1] Randomized algorithms for matrices and data, Michael W. Mahoney (page 7), https://arxiv.org/pdf/1104.5557.pdf

[2] Fast Approximation of Matrix Coherence and Statistical Leverage, Petros Drineas and Malik Magdon-Ismail and Michael W. Mahoney and David P. Woodruff, JMLR, https://www.stat.berkeley.edu/~mmahoney/pubs/coherence-jmlr12.pdf

spalor.matrix_tools.leverage_score.leverage_score_aprx(X, c1, c2)[source]
spalor.matrix_tools.leverage_score.leverage_score_exact(X, r=10)[source]