Github user jkbradley commented on a diff in the pull request:

    https://github.com/apache/spark/pull/4580#discussion_r29816082
  
    --- Diff: 
mllib/src/test/scala/org/apache/spark/mllib/feature/ElementwiseProductSuite.scala
 ---
    @@ -0,0 +1,83 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.mllib.feature
    +
    +import org.apache.spark.mllib.linalg.{SparseVector, DenseVector, Vector, 
Vectors}
    +import org.apache.spark.mllib.util.MLlibTestSparkContext
    +import org.scalatest.FunSuite
    +import org.apache.spark.mllib.util.TestingUtils._
    +
    +class ElementwiseProductSuite extends FunSuite with MLlibTestSparkContext{
    +
    +  val denseData =  Array(
    +    Vectors.dense(1.0, 1.0, 0.0, 0.0),
    +    Vectors.dense(1.0, 2.0, -3.0, 0.0),
    +    Vectors.dense(1.0, 3.0, 0.0, 0.0),
    +    Vectors.dense(1.0, 4.0, 1.9, -9.0),
    +    Vectors.dense(1.0, 5.0, 0.0, 0.0)
    +  )
    +
    +  val sparseData = Array(
    +    Vectors.sparse(3, Seq((0, -2.0), (1, 2.3))),
    +    Vectors.sparse(3, Seq((1, -1.0), (2, -3.0))),
    +    Vectors.sparse(3, Seq((1, -5.1))),
    +    Vectors.sparse(3, Seq((0, 3.8), (2, 1.9))),
    +    Vectors.sparse(3, Seq((0, 1.7), (1, -0.6))),
    +    Vectors.sparse(3, Seq((1, 1.9)))
    +  )
    +
    +  val scalingVector = Vectors.dense(2.0, 0.5, 0.0, 0.25)
    +
    +  test("elementwise (hadamard) product should properly apply vector to 
dense data set") {
    +
    +    val transformer = new ElementwiseProduct(scalingVector)
    +    val transformedData = transformer.transform(sc.makeRDD(denseData))
    +
    +    val transformedVecs = transformedData.collect()
    --- End diff --
    
    collect() isn't guaranteed to return data in the same order.  I'd recommend 
testing using per-row transform(); transforming RDDs is already tested 
elsewhere since you're using the VectorTransformer abstraction.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at [email protected] or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to