Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Clustering -- Sparse vector and Dense Vector

Tags:

mahout

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 ?

like image 999
Ramana Avatar asked Jul 28 '13 16:07

Ramana


1 Answers

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.

like image 109
Shlomo Georg Konwisser Avatar answered Oct 29 '22 10:10

Shlomo Georg Konwisser