Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
renamed scalingVector to scalingVec
  • Loading branch information
jkbradley committed Jun 2, 2015
commit d3812f8b5c4965180e21c6cf62e777bedf1f8282
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class ElementwiseProduct(override val uid: String)
* the vector to multiply with input vectors
* @group param
*/
val scalingVec: Param[Vector] = new Param(this, "scalingVector", "vector for hadamard product")
val scalingVec: Param[Vector] = new Param(this, "scalingVec", "vector for hadamard product")

/** @group setParam */
def setScalingVec(value: Vector): this.type = set(scalingVec, value)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ import org.apache.spark.mllib.linalg._
* Outputs the Hadamard product (i.e., the element-wise product) of each input vector with a
* provided "weight" vector. In other words, it scales each column of the dataset by a scalar
* multiplier.
* @param scalingVector The values used to scale the reference vector's individual components.
* @param scalingVec The values used to scale the reference vector's individual components.
*/
@Experimental
class ElementwiseProduct(val scalingVector: Vector) extends VectorTransformer {
class ElementwiseProduct(val scalingVec: Vector) extends VectorTransformer {

/**
* Does the hadamard product transformation.
Expand All @@ -37,15 +37,15 @@ class ElementwiseProduct(val scalingVector: Vector) extends VectorTransformer {
* @return transformed vector.
*/
override def transform(vector: Vector): Vector = {
require(vector.size == scalingVector.size,
s"vector sizes do not match: Expected ${scalingVector.size} but found ${vector.size}")
require(vector.size == scalingVec.size,
s"vector sizes do not match: Expected ${scalingVec.size} but found ${vector.size}")
vector match {
case dv: DenseVector =>
val values: Array[Double] = dv.values.clone()
val dim = scalingVector.size
val dim = scalingVec.size
var i = 0
while (i < dim) {
values(i) *= scalingVector(i)
values(i) *= scalingVec(i)
i += 1
}
Vectors.dense(values)
Expand All @@ -54,7 +54,7 @@ class ElementwiseProduct(val scalingVector: Vector) extends VectorTransformer {
val dim = values.length
var i = 0
while (i < dim) {
values(i) *= scalingVector(indices(i))
values(i) *= scalingVec(indices(i))
i += 1
}
Vectors.sparse(size, indices, values)
Expand Down