首页 > 代码库 > scala 稀疏向量

scala 稀疏向量

http://mocom.xmu.edu.cn/article/show/58481eb2e083c990247075a5/0/1

 

/创建一个标签为1.0(分类中可视为正样本)的稠密向量标注点 scala> val pos = LabeledPoint(1.0, Vectors.dense(2.0, 0.0, 8.0)) pos: org.apache.spark.mllib.regression.LabeledPoint = (1.0,[2.0,0.0,8.0]) //创建一个标签为0.0(分类中可视为负样本)的稀疏向量标注点 scala> val neg = LabeledPoint(0.0, Vectors.sparse(3, Array(0, 2), Array(2.0, 8.0))) neg: org.apache.spark.mllib.regression.LabeledPoint = (0.0,(3,[0,2],[2.0,8.0]))

scala 稀疏向量