Skip to content

Commit 5e068e3

Browse files
committed
[MLlib] Minor: UDF style update.
1 parent 84acd08 commit 5e068e3

File tree

2 files changed

+5
-3
lines changed

2 files changed

+5
-3
lines changed

mllib/src/main/scala/org/apache/spark/ml/classification/LogisticRegression.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ class LogisticRegressionModel private[ml] (
137137
1.0 / (1.0 + math.exp(-margin))
138138
} : Double)
139139
val t = map(threshold)
140-
val predictFunction = udf((score: Double) => { if (score > t) 1.0 else 0.0 } : Double)
140+
val predictFunction = udf { score: Double =>
141+
if (score > t) 1.0 else 0.0
142+
}
141143
dataset
142144
.select($"*", scoreFunction(col(map(featuresCol))).as(map(scoreCol)))
143145
.select($"*", predictFunction(col(map(scoreCol))).as(map(predictionCol)))

mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -129,13 +129,13 @@ class ALSModel private[ml] (
129129

130130
// Register a UDF for DataFrame, and then
131131
// create a new column named map(predictionCol) by running the predict UDF.
132-
val predict = udf((userFeatures: Seq[Float], itemFeatures: Seq[Float]) => {
132+
val predict = udf { (userFeatures: Seq[Float], itemFeatures: Seq[Float]) =>
133133
if (userFeatures != null && itemFeatures != null) {
134134
blas.sdot(k, userFeatures.toArray, 1, itemFeatures.toArray, 1)
135135
} else {
136136
Float.NaN
137137
}
138-
} : Float)
138+
}
139139
dataset
140140
.join(users, dataset(map(userCol)) === users("id"), "left")
141141
.join(items, dataset(map(itemCol)) === items("id"), "left")

0 commit comments

Comments
 (0)