spark-reviews mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yunni <...@git.apache.org>
Subject [GitHub] spark pull request #15874: [Spark-18408][ML] API Improvements for LSH
Date Wed, 16 Nov 2016 01:12:27 GMT
Github user Yunni commented on a diff in the pull request:

    https://github.com/apache/spark/pull/15874#discussion_r88150618
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/feature/LSH.scala ---
    @@ -179,16 +211,13 @@ private[ml] abstract class LSHModel[T <: LSHModel[T]]
           inputName: String,
           explodeCols: Seq[String]): Dataset[_] = {
         require(explodeCols.size == 2, "explodeCols must be two strings.")
    -    val vectorToMap = udf((x: Vector) => x.asBreeze.iterator.toMap,
    -      MapType(DataTypes.IntegerType, DataTypes.DoubleType))
         val modelDataset: DataFrame = if (!dataset.columns.contains($(outputCol))) {
           transform(dataset)
         } else {
           dataset.toDF()
         }
         modelDataset.select(
    -      struct(col("*")).as(inputName),
    -      explode(vectorToMap(col($(outputCol)))).as(explodeCols))
    +      struct(col("*")).as(inputName), posexplode(col($(outputCol))).as(explodeCols))
    --- End diff --
    
    Yes, I copied your code to `BucketedRandomProjectionLSHSuite.scala` and it runs fine for
me with the following output:
    ```
    +--------------------+--------------------+------------------+
    |            datasetA|            datasetB|           distCol|
    +--------------------+--------------------+------------------+
    |[(50,[0],[-2.0]),...|[(50,[0],[-1.0]),...|               1.0|
    |[(50,[4],[-1.0]),...|[(50,[23],[-1.0])...|1.4142135623730951|
    |[(50,[5],[-1.0]),...|[(50,[32],[-1.0])...|1.4142135623730951|
    |[(50,[7],[1.0]),W...|[(50,[47],[1.0]),...|1.4142135623730951|
    |[(50,[7],[2.0]),W...|[(50,[26],[-2.0])...|2.8284271247461903|
    |[(50,[8],[-2.0]),...|[(50,[1],[-1.0]),...|  2.23606797749979|
    |[(50,[8],[-1.0]),...|[(50,[23],[-2.0])...|  2.23606797749979|
    |[(50,[10],[-1.0])...|[(50,[7],[2.0]),W...|  2.23606797749979|
    |[(50,[10],[-1.0])...|[(50,[13],[2.0]),...|  2.23606797749979|
    |[(50,[11],[-1.0])...|[(50,[39],[2.0]),...|  2.23606797749979|
    |[(50,[12],[-2.0])...|[(50,[28],[1.0]),...|  2.23606797749979|
    |[(50,[12],[-2.0])...|[(50,[29],[-1.0])...|  2.23606797749979|
    |[(50,[13],[1.0]),...|[(50,[2],[-2.0]),...|  2.23606797749979|
    |[(50,[14],[1.0]),...|[(50,[33],[2.0]),...|  2.23606797749979|
    |[(50,[14],[2.0]),...|[(50,[28],[2.0]),...|2.8284271247461903|
    |[(50,[15],[-1.0])...|[(50,[38],[-1.0])...|1.4142135623730951|
    |[(50,[18],[1.0]),...|[(50,[8],[-1.0]),...|1.4142135623730951|
    |[(50,[18],[1.0]),...|[(50,[12],[-2.0])...|  2.23606797749979|
    |[(50,[18],[2.0]),...|[(50,[43],[1.0]),...|  2.23606797749979|
    |[(50,[20],[1.0]),...|[(50,[25],[-1.0])...|1.4142135623730951|
    +--------------------+--------------------+------------------+
    only showing top 20 rows
    
    Let me see if the test can pass jenkins or not.
    ```


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


Mime
View raw message