> This is n_features x n_features, right? This is never going to fit in memory if the number of features is large. Surely there must be a bteer way of doing this (the matrix is low rank, you don't need to store it, nor to use it in the computation).

you're right... let me have a look