spark-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From r...@apache.org
Subject spark git commit: [MLlib] Minor: UDF style update.
Date Thu, 05 Feb 2015 07:58:06 GMT
Repository: spark
Updated Branches:
  refs/heads/master 7d789e117 -> c3ba4d4cd


[MLlib] Minor: UDF style update.

Author: Reynold Xin <rxin@databricks.com>

Closes #4388 from rxin/mllib-style and squashes the following commits:

61d465b [Reynold Xin] oops
3364295 [Reynold Xin] Missed one ..
5e068e3 [Reynold Xin] [MLlib] Minor: UDF style update.


Project: http://git-wip-us.apache.org/repos/asf/spark/repo
Commit: http://git-wip-us.apache.org/repos/asf/spark/commit/c3ba4d4c
Tree: http://git-wip-us.apache.org/repos/asf/spark/tree/c3ba4d4c
Diff: http://git-wip-us.apache.org/repos/asf/spark/diff/c3ba4d4c

Branch: refs/heads/master
Commit: c3ba4d4cd032e376bfdf7ea7eaab65a79a771e7e
Parents: 7d789e1
Author: Reynold Xin <rxin@databricks.com>
Authored: Wed Feb 4 23:57:53 2015 -0800
Committer: Reynold Xin <rxin@databricks.com>
Committed: Wed Feb 4 23:57:53 2015 -0800

----------------------------------------------------------------------
 .../apache/spark/ml/classification/LogisticRegression.scala  | 8 +++++---
 .../main/scala/org/apache/spark/ml/recommendation/ALS.scala  | 4 ++--
 2 files changed, 7 insertions(+), 5 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/spark/blob/c3ba4d4c/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
----------------------------------------------------------------------
diff --git a/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
b/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
index df90078..b46a5cd 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala
@@ -132,12 +132,14 @@ class LogisticRegressionModel private[ml] (
   override def transform(dataset: DataFrame, paramMap: ParamMap): DataFrame = {
     transformSchema(dataset.schema, paramMap, logging = true)
     val map = this.paramMap ++ paramMap
-    val scoreFunction = udf((v: Vector) => {
+    val scoreFunction = udf { v: Vector =>
       val margin = BLAS.dot(v, weights)
       1.0 / (1.0 + math.exp(-margin))
-    } : Double)
+    }
     val t = map(threshold)
-    val predictFunction = udf((score: Double) => { if (score > t) 1.0 else 0.0 } :
Double)
+    val predictFunction = udf { score: Double =>
+      if (score > t) 1.0 else 0.0
+    }
     dataset
       .select($"*", scoreFunction(col(map(featuresCol))).as(map(scoreCol)))
       .select($"*", predictFunction(col(map(scoreCol))).as(map(predictionCol)))

http://git-wip-us.apache.org/repos/asf/spark/blob/c3ba4d4c/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala
----------------------------------------------------------------------
diff --git a/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala b/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala
index 09456b2..bf57371 100644
--- a/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala
+++ b/mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala
@@ -129,13 +129,13 @@ class ALSModel private[ml] (
 
     // Register a UDF for DataFrame, and then
     // create a new column named map(predictionCol) by running the predict UDF.
-    val predict = udf((userFeatures: Seq[Float], itemFeatures: Seq[Float]) => {
+    val predict = udf { (userFeatures: Seq[Float], itemFeatures: Seq[Float]) =>
       if (userFeatures != null && itemFeatures != null) {
         blas.sdot(k, userFeatures.toArray, 1, itemFeatures.toArray, 1)
       } else {
         Float.NaN
       }
-    } : Float)
+    }
     dataset
       .join(users, dataset(map(userCol)) === users("id"), "left")
       .join(items, dataset(map(itemCol)) === items("id"), "left")


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


Mime
View raw message