Clustering -- Sparse vector and Dense Vector
Asked Answered
E

1

13

For clustering, Mahout input needs to be in vector form. There are two types of vector implementations. One is Sparse Vector and another is Dense Vector.

What is difference between two ?

Usage scenarios for Sparse and Dense ?

Economizer answered 28/7, 2013 at 16:23 Comment(0)
W
20

Concept-wise, most of the values in a sparse vector are zero, in a dense vector they are not. Same for dense and sparse matrices. The terms sparse and dense generally describe these properties, not only in Mahout.

In Mahout the DenseVector assumes not too many zero entries and therefore "Implements vector as an array of doubles" (org.apache.mahout.math.DenseVector). In contrast, the sparse vector implementations of AbstractVector, e.g. RandomAccessSparseVector and SequentialAccessSparseVector, use different data structures which don't store the zero values at all.

Which one to take depends on the data you want to store in the vector. If you expect mostly zero values, a sparse vector implementation would be more space efficient, however if you use it for data with just a few zero values you introduce a lot of data structure overhead which could cause worse performance.

The choice of dense vs. sparse vector does not affect your calculation results on the vectors, only memory usage and calculation speed.

Weakminded answered 3/11, 2014 at 1:27 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.