Clustering — Sparse vector and Dense Vector

后端 未结 1 1272
生来不讨喜
生来不讨喜 2021-02-03 11:37

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 differe

相关标签:
1条回答
  • 2021-02-03 12:03

    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.

    0 讨论(0)
提交回复
热议问题