【问题标题】:sparse Matrix/ CSC Matrix in pysparkpyspark中的稀疏矩阵/ CSC矩阵
【发布时间】:2021-06-30 05:51:28
【问题描述】:

谁能解释一下稀疏矩阵或CSC矩阵。

Column-major sparse matrix. The entry values are stored in Compressed Sparse Column (CSC) format. For example, the following matrix

   1.0 0.0 4.0
   0.0 3.0 5.0
   2.0 0.0 6.0
 
is stored as values: [1.0, 2.0, 3.0, 4.0, 5.0, 6.0], rowIndices=[0, 2, 1, 0, 1, 2], colPointers=[0, 2, 3, 6].

上面的例子是从https://spark.apache.org/docs/1.6.1/api/java/org/apache/spark/mllib/linalg/SparseMatrix.html得到的

但是,我得到了什么是值和 RowIndices 但不了解 colpointer。谁能帮助我理解它。

【问题讨论】:

标签: python apache-spark pyspark sparse-matrix


【解决方案1】:
[0, 2, 3, 6]

第一列[0:2]的数据和行索引

第二列[2:3]

第三次[3:6]

或者换个角度看,[2,1,3] 的区别告诉我们每列有多少个词。

【讨论】:

    猜你喜欢
    • 2020-05-31
    • 2017-03-26
    • 2015-12-05
    • 2018-01-19
    • 1970-01-01
    • 1970-01-01
    • 2015-04-26
    • 1970-01-01
    • 2017-07-20
    相关资源
    最近更新 更多