ElementwiseProduct

class pyspark.mllib.feature.ElementwiseProduct(scalingVector)[source]

Scales each column of the vector, with the supplied weight vector. i.e the elementwise product.

New in version 1.5.0.

Examples

>>> 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])]

Methods

transform(vector)

Computes the Hadamard product of the vector.

Methods Documentation

transform(vector)[source]

Computes the Hadamard product of the vector.

New in version 1.5.0.