Skip to content

Commit

Permalink
[SPARK-8053] [MLLIB] renamed scalingVector to scalingVec
Browse files Browse the repository at this point in the history
I searched the Spark codebase for all occurrences of "scalingVector"

CC: mengxr

Author: Joseph K. Bradley <[email protected]>

Closes apache#6596 from jkbradley/scalingVec-rename and squashes the following commits:

d3812f8 [Joseph K. Bradley] renamed scalingVector to scalingVec
  • Loading branch information
jkbradley authored and jeanlyn committed Jun 12, 2015
1 parent 00cbbfa commit 655fa53
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
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

0 comments on commit 655fa53

Please sign in to comment.