當前位置: 首頁>>編程示例 >>用法及示例精選 >>正文


Python pyspark ElementwiseProduct用法及代碼示例

本文簡要介紹 pyspark.mllib.feature.ElementwiseProduct 的用法。

用法:

class pyspark.mllib.feature.ElementwiseProduct(scalingVector)

使用提供的權重向量縮放向量的每一列。即元素乘積。

1.5.0 版中的新函數。

例子

>>> weight = Vectors.dense([1.0, 2.0, 3.0])
>>> eprod = ElementwiseProduct(weight)
>>> a = Vectors.dense([2.0, 1.0, 3.0])
>>> eprod.transform(a)
DenseVector([2.0, 2.0, 9.0])
>>> b = Vectors.dense([9.0, 3.0, 4.0])
>>> rdd = sc.parallelize([a, b])
>>> eprod.transform(rdd).collect()
[DenseVector([2.0, 2.0, 9.0]), DenseVector([9.0, 6.0, 12.0])]

相關用法


注:本文由純淨天空篩選整理自spark.apache.org大神的英文原創作品 pyspark.mllib.feature.ElementwiseProduct。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。