ElementwiseProduct

class pyspark.mllib.feature.ElementwiseProduct(scalingVector: pyspark.mllib.linalg.Vector)[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: Union[VectorLike, pyspark.rdd.RDD[VectorLike]]) → Union[pyspark.mllib.linalg.Vector, pyspark.rdd.RDD[pyspark.mllib.linalg.Vector]][source]

Computes the Hadamard product of the vector.

New in version 1.5.0.