Hi Mike, and thanks for the quick response.
There are two things I'm trying to do: the first is to write out a sparse matrix to file in the matrix market format. For this I need to doseq over only the matrix's non-zero indexes, and print them out line by line. So a sparse matrix that looks like this:
[[0.0 0.0 2.3]
[0.0 0.7 0.0]
[0.0 0.0 0.0]]
I want to print like this:
The second thing I would like to be able to do is to map a function over all the non-zero elements of a sparse matrix. The specific reason I want to do this is the following:
I have a large set of documents made up of about 300 different, non-overlapping subgroups of documents. I want to calculate TF-IDF for each subgroup individually, where the "document" is an individual document, but I also want to calculate an overall TF-IDF that treats each subgroup as a whole as a single "document".
I started by, for each subgroup, counting the number of documents in which each term appears. So I have one matrix per subgroup that contains the number of documents within the subgroup that contain each term. Now I want to combine those matrices into one that contains the counts of subgroups that contain each term.
My initial idea of how to achieve this was to somehow map the function (constantly 1) over the non-zero elements of the matrices and then reduce them with m/add. But I'm not sure if that's possible and/or easy. Or if there's a simple alternative way to do it. I don't have any grounding in linear algebra other than what I was able to scrape together while doing a Coursera ML course, so I am very much blundering my way round.
Thanks again for your help,
Russell