在通过VectorAssembler将多列特征值和并后,由于spark存储格式的原因,会将含有很多0值的一行转为稀疏向量sparseVector
进行存储。然而在后续计算过程中,我们需要的是密集向量,所以需要将稀疏向量转为密集向量。

1.先通过VectorAssembler将需要的列转成向量列
2.转为RDD后map操作,将feature列中的元素转为DenseVector
在这里插入图片描述
spark中稀疏向量转密集向量

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-11-25
  • 2021-10-16
  • 2022-12-23
  • 2021-12-26
  • 2022-12-23
  • 2021-06-03
猜你喜欢
  • 2022-02-05
  • 2021-10-06
  • 2021-06-06
  • 2021-05-02
  • 2021-09-26
  • 2022-12-23
  • 2022-02-14
相关资源
相似解决方案