1
Spark 1.5最近出來了,並且在Python中有元素明智的乘法(http://spark.apache.org/docs/latest/mllib-feature-extraction.html)。Spark 1.5 Elementwise Product
我沒有任何問題在矢量上應用加權/變換矢量(在我的代碼中,v2)來產生矢量。然而,當我試圖把它在RDD [矢量],我得到:
TypeError: Cannot convert type < type 'numpy.float64'> into Vector.
這裏是我的代碼:
from pyspark.mllib.linalg import Vectors
from pyspark.mllib.feature import ElementwiseProduct
v1 = sc.parallelize(Vectors.dense([2.0, 2.0, 2.0]))
v2 = Vectors.dense([0.0, 1.0, 2.0])
transformer = ElementwiseProduct(v2)
transformedData = transformer.transform(v1)
print transformedData.collect()
我如何產生RDD [矢量]這是V1的阿達瑪產品和v2?